Open coaxial opened 3 years ago
Given an ormconfig.js file with:
module.exports = { // ... seeds: ['src/**/*.seed.ts'], factories: ['src/**/*.factory.ts], }
The ormconfig file is located at apps/api/src/config/ormconfig.js within a monorepo, and package.json is located at ./process.cwd().
apps/api/src/config/ormconfig.js
package.json
.
process.cwd()
Then the file loader fails to find the factory or seed files.
However, if I change this line: https://github.com/w3tecch/typeorm-seeding/blob/4136b0e0f58a4ec13b17c717bd026043fbdf7ddd/src/utils/file.util.ts#L10 to .map((pattern) => glob.sync(path.resolve(process.cwd(), 'apps/api', pattern))), then it finds the seed and factory files.
.map((pattern) => glob.sync(path.resolve(process.cwd(), 'apps/api', pattern)))
Specifying a root with the -r argument at the CLI should, in my opinion, alter the way that fonction resolves paths to find the globs from the ormconfig.
-r
Given an ormconfig.js file with:
The ormconfig file is located at
apps/api/src/config/ormconfig.js
within a monorepo, andpackage.json
is located at.
/process.cwd()
.Then the file loader fails to find the factory or seed files.
However, if I change this line: https://github.com/w3tecch/typeorm-seeding/blob/4136b0e0f58a4ec13b17c717bd026043fbdf7ddd/src/utils/file.util.ts#L10 to
.map((pattern) => glob.sync(path.resolve(process.cwd(), 'apps/api', pattern)))
, then it finds the seed and factory files.Specifying a root with the
-r
argument at the CLI should, in my opinion, alter the way that fonction resolves paths to find the globs from the ormconfig.