in src/config.ts [30:64]
export async function readConfig(
env: string,
config?: string
): Promise<SyntheticsConfig> {
let options = {};
const cwd = process.cwd();
/**
* If config is passed via `--config` flag, try to resolve it relative to the
* current working directory
*/
if (typeof config === 'string') {
const configPath = resolveConfigPath(config, cwd);
options = readAndParseConfig(configPath);
} else {
/**
* resolve to `synthetics.config.js` and `synthetics.config.ts`
* recursively till root
*/
const configPath = findSyntheticsConfig(cwd, cwd);
configPath && (options = readAndParseConfig(configPath));
}
if (typeof options === 'function') {
options = options(env);
const optionsPromise = options as Promise<SyntheticsConfig>;
if (
optionsPromise != null &&
typeof optionsPromise.then === 'function' &&
typeof optionsPromise.catch === 'function'
) {
options = await optionsPromise;
}
}
return options;
}