MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / getConfigPaths

Method getConfigPaths

packages/cli/src/CLIHelper.ts:158–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

156 }
157
158 static async getConfigPaths(): Promise<string[]> {
159 const settings = this.getSettings();
160 const typeScriptSupport = settings.preferTs ?? Utils.detectTypeScriptSupport();
161 const paths: string[] = [];
162
163 if (process.env.MIKRO_ORM_CLI_CONFIG) {
164 paths.push(process.env.MIKRO_ORM_CLI_CONFIG);
165 }
166
167 paths.push(...(settings.configPaths || []));
168
169 if (typeScriptSupport) {
170 paths.push('./src/mikro-orm.config.ts');
171 paths.push('./mikro-orm.config.ts');
172 }
173
174 const distDir = fs.pathExists(process.cwd() + '/dist');
175 const buildDir = fs.pathExists(process.cwd() + '/build');
176 /* v8 ignore next */
177 const path = distDir ? 'dist' : buildDir ? 'build' : 'src';
178 paths.push(`./${path}/mikro-orm.config.js`);
179 paths.push('./mikro-orm.config.js');
180
181 /* v8 ignore next */
182 return Utils.unique(paths).filter(p => !/\.[mc]?ts$/.exec(p) || typeScriptSupport);
183 }
184
185 private static async getConfigFile(paths: string[]): Promise<[string, unknown] | []> {
186 for (let path of paths) {

Callers 5

getConfigurationMethod · 0.95
handlerMethod · 0.80
resolveOutputPathMethod · 0.80
handlerMethod · 0.80
CLIHelper.test.tsFile · 0.80

Calls 6

getSettingsMethod · 0.95
pushMethod · 0.80
pathExistsMethod · 0.80
filterMethod · 0.80
uniqueMethod · 0.65

Tested by

no test coverage detected