* Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it. * If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be * used for the TS variant (`pathTs` option). * *
(fs: { pathExists(path: string): boolean })
| 489 | * break existing projects, only help with the new ones. |
| 490 | */ |
| 491 | private detectSourceFolder(fs: { pathExists(path: string): boolean }): void { |
| 492 | const baseDir = this.config.get('baseDir'); |
| 493 | const defaultPath = './migrations'; |
| 494 | |
| 495 | if (!fs.pathExists(baseDir + '/src')) { |
| 496 | this.options.path ??= defaultPath; |
| 497 | return; |
| 498 | } |
| 499 | |
| 500 | const exists = fs.pathExists(`${baseDir}/${defaultPath}`); |
| 501 | const distDir = fs.pathExists(baseDir + '/dist'); |
| 502 | const buildDir = fs.pathExists(baseDir + '/build'); |
| 503 | // if neither `dist` nor `build` exist, we use the `src` folder as it might be a JS project without building, but with `src` folder |
| 504 | /* v8 ignore next */ |
| 505 | const path = distDir ? './dist' : buildDir ? './build' : './src'; |
| 506 | |
| 507 | // only if the user did not provide any values and if the default path does not exist |
| 508 | if (!this.options.path && !this.options.pathTs && !exists) { |
| 509 | this.options.path = `${path}/migrations`; |
| 510 | this.options.pathTs = './src/migrations'; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | private registerDefaultListeners(): void { |
| 515 | /* v8 ignore else */ |
nothing calls this directly
no test coverage detected