@typed/test
Version:
Testing made simple.
18 lines • 801 B
JavaScript
import * as fs from 'fs';
import { findConfigFile } from 'typescript';
import { transpileFile } from '../typescript/transpileFile';
export function findTypedTestConfigs(compilerOptions, cwd = process.cwd()) {
const configPath = findConfigFile(cwd, (fileName) => fs.existsSync(fileName), '.typed-test.ts');
if (!configPath) {
return [{}];
}
const configContents = fs.readFileSync(configPath).toString();
const { content } = transpileFile(configContents, compilerOptions, cwd);
// tslint:disable-next-line:no-eval
const configModule = eval(content);
return configModule.default ? toArrayIfNot(configModule.default) : toArrayIfNot(configModule);
}
function toArrayIfNot(x) {
return Array.isArray(x) ? x : [x];
}
//# sourceMappingURL=findTypedTestConfigs.js.map