Skip to content

Commit

Permalink
fix(config): use the file:// protocol to import ts config files
Browse files Browse the repository at this point in the history
  • Loading branch information
umbopepato committed Jun 8, 2020
1 parent 75667ee commit e82be9c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/load_config.ts
Expand Up @@ -41,14 +41,13 @@ function parent(dir: string) {

async function parseConfig(
configPath: string,
isJavascript: boolean,
isTypescript: boolean,
): Promise<ScriptsConfiguration> {
return new Promise(async (resolve: any) => {
if (isJavascript) {
return resolve(await import(configPath));
}
return resolve(parseYaml(
readFileStrSync(configPath, { encoding: "utf8" }),
) as ScriptsConfiguration);
});
if (isTypescript) {
return (await import(`file://${configPath}`))
.default as ScriptsConfiguration;
}
return parseYaml(
readFileStrSync(configPath, { encoding: "utf8" }),
) as ScriptsConfiguration;
}

0 comments on commit e82be9c

Please sign in to comment.