Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!utils_1.endsWith(tsConfigFilePath, ".json")) {
tsConfigFilePath = path.join(tsConfigFilePath, utils_1.CONFIG_FILENAME);
}
return [4 /*yield*/, tsconfig.readFile(tsConfigFilePath)];
case 1:
config = _a.sent();
utils_1.validateTsConfig(config);
outDir = path.resolve(path.dirname(tsConfigFilePath), config.compilerOptions.outDir);
jsFiles = utils_1.getJSFiles(outDir);
if (!jsFiles.length) {
throw new Error("No .js files found");
}
modules = Object.keys(config.compilerOptions.paths);
return [4 /*yield*/, Promise.all(jsFiles.map(function (filePath) {
var tsModules = [];
for (var _i = 0, modules_2 = modules; _i < modules_2.length; _i++) {
var moduleName = modules_2[_i];
var modulePath = utils_1.rtrim(config.compilerOptions.paths[moduleName][0], "*"); // Remove trailing *s
tsModules.push({ name: moduleName, path: modulePath });
}
export async function resolve(tsConfigFilePath: string) {
if (!endsWith(tsConfigFilePath, ".json")) {
tsConfigFilePath = path.join(tsConfigFilePath, CONFIG_FILENAME);
}
const config: any = await tsconfig.readFile(tsConfigFilePath);
validateTsConfig(config);
const outDir = path.resolve(path.dirname(tsConfigFilePath), config.compilerOptions.outDir);
const jsFiles: string[] = getJSFiles(outDir);
if (!jsFiles.length) {
throw new Error("No .js files found");
}
const modules = Object.keys(config.compilerOptions.paths);
await Promise.all(
jsFiles.map((filePath: string) => {
const tsModules: ITypescriptModule[] = [];
for (const moduleName of modules) {
const modulePath = rtrim(config.compilerOptions.paths[moduleName][0], "*"); // Remove trailing *s
tsModules.push({ name: moduleName, path: modulePath });
}