File tree Expand file tree Collapse file tree 6 files changed +37
-13
lines changed
seed-sqlite-js-ts-default-export
seed-sqlite-js-ts-named-export Expand file tree Collapse file tree 6 files changed +37
-13
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "lib" : [" DOM" , " ES2016" ]
4+ }
5+ }
Original file line number Diff line number Diff line change 1- function seed ( ) {
2- return 'hello from "seed" named export from seed.js'
1+ async function seed ( ) {
2+ await new Promise ( ( _ ) => null ) // eslint-disable-line @typescript-eslint/no-unused-vars
3+ return 'hello from async "seed" named export from seed.js'
34}
45
56if ( require . main === module ) {
Original file line number Diff line number Diff line change 22declare const require : any
33declare const module : any
44
5- function seed ( ) {
6- return 'hello from "seed" named export from seed.ts'
5+ async function seed ( ) {
6+ await new Promise ( ( _ ) => null ) // eslint-disable-line @typescript-eslint/no-unused-vars
7+ return 'hello from async "seed" named export from seed.ts'
78}
89
910if ( require . main === module ) {
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "lib" : [" DOM" , " ES2016" ]
4+ }
5+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "lib" : [" DOM" , " ES2016" ]
4+ }
5+ }
Original file line number Diff line number Diff line change @@ -69,19 +69,26 @@ export function detectSeedFiles(schemaPath) {
6969
7070function getSeedScript ( type : 'TS' | 'JS' , seedFilepath : string ) {
7171 let script = `
72+ console.info('Result:')
73+
7274const __seed = require('./${ seedFilepath } ')
7375const __keys = Object.keys(__seed)
7476
75- // Execute "seed" named export or default export
76- if (__keys && __keys.length) {
77- if (__keys.indexOf('seed') !== -1) {
78- __seed.seed()
79- } else if (__keys.indexOf('default') !== -1) {
80- __seed.default()
77+ async function runSeed() {
78+ // Execute "seed" named export or default export
79+ if (__keys && __keys.length) {
80+ if (__keys.indexOf('seed') !== -1) {
81+ return await __seed.seed()
82+ } else if (__keys.indexOf('default') !== -1) {
83+ return await __seed.default()
84+ }
85+ } else {
86+ return ''
8187 }
82- } else {
83- ''
84- }`
88+ }
89+
90+ runSeed()
91+ `
8592
8693 if ( type === 'TS' ) {
8794 script = `
You can’t perform that action at this time.
0 commit comments