Open
Description
Basically, when the seeder file has some export const foo = 'bar'
-ish statement, the run
method is not invoked and the output is this:
π± TypeORM Seeding v1.6.1
β ORM Config loaded
β Factories are imported
β Seeders are imported
β Connecting to the databaseINFO: All classes found using provided glob pattern xxx
INFO: All classes found using provided glob pattern xxx
β Database connected
π Finished Seeding
I think that typeorm-seeding CLI should ignore these statements regardless of whether it is right or not to have them in a seeder file.
I've notice that this behavior is due to seedFileObject[keys[0]]
typeorm-seeding/src/importer.ts
Lines 3 to 7 in 4136b0e
because this will return the foo
variable instead of the seeder class. I've thought that return seedFileObject.default
was enough but @hirsch88 already use this in the past with require
(on 84df811)
Maybe this should work but I'm not sure:
export const importSeed = async (filePath: string): Promise<SeederConstructor> => {
const seedFileObject: { [key: string]: SeederConstructor } = await import(filePath)
return seedFileObject.default
}