Skip to content

Commit

Permalink
build: use sync file loading, since ts transpiled import -> require
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Nov 29, 2022
1 parent c0c95d4 commit 79e2e02
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"license": "MIT",
"dependencies": {
"@faker-js/faker": "^7.6.0",
"locter": "^0.3.2",
"rapiq": "^0.5.0",
"locter": "^0.5.1",
"rapiq": "^0.6.0",
"reflect-metadata": "^0.1.13",
"yargs": "^17.6.2"
},
Expand Down
8 changes: 6 additions & 2 deletions src/data-source/find/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { loadScriptFile, locateFile, removeFileNameExtension } from 'locter';
import {
loadScriptFileSync,
locateFile,
removeFileNameExtension,
} from 'locter';
import path from 'path';
import { DataSource, InstanceChecker } from 'typeorm';
import { DataSourceFindOptions } from './type';
Expand Down Expand Up @@ -79,7 +83,7 @@ export async function findDataSource(
});

if (info) {
const fileExports = await loadScriptFile(info);
const fileExports = loadScriptFileSync(info);
if (InstanceChecker.isDataSource(fileExports)) {
return fileExports;
}
Expand Down
9 changes: 6 additions & 3 deletions src/seeder/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import { loadScriptFile, loadScriptFileExport } from 'locter';
import {
loadScriptFileExportSync,
loadScriptFileSync,
} from 'locter';
import { SeederConstructor, SeederOptions } from './type';
import { resolveFilePaths, resolveFilePatterns, setDefaultSeederOptions } from './utils';
import { modifyDataSourceOptionForRuntimeEnvironment, setDataSource } from '../data-source';
Expand Down Expand Up @@ -32,7 +35,7 @@ async function prepareSeeder(
factoryFiles = resolveFilePaths(factoryFiles);

for (let i = 0; i < factoryFiles.length; i++) {
await loadScriptFile(factoryFiles[i]);
loadScriptFileSync(factoryFiles[i]);
}
}

Expand Down Expand Up @@ -68,7 +71,7 @@ async function prepareSeeder(
seedFiles = resolveFilePaths(seedFiles);

for (let i = 0; i < seedFiles.length; i++) {
const fileExport = await loadScriptFileExport(seedFiles[i]);
const fileExport = loadScriptFileExportSync(seedFiles[i]);
if (fileExport) {
const item = fileExport.value as SeederConstructor;

Expand Down

0 comments on commit 79e2e02

Please sign in to comment.