From ac3d1349af065fc754eaec3ddfbd10af3f132817 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 1 Oct 2021 23:44:38 +0200 Subject: [PATCH] Return the outputFilePath and require it in the lib --- src/index.ts | 2 +- src/run.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 45b4c98..fd190a9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import * as Run from './run'; export async function run(options: { inputFilePath: string | undefined, - outputFilePath: string | null, + outputFilePath: string, optimizeSpeed: boolean, processOpts: { stdio: [string, string, string], diff --git a/src/run.ts b/src/run.ts index 71a38b6..42b5281 100644 --- a/src/run.ts +++ b/src/run.ts @@ -12,7 +12,7 @@ import * as fs from 'fs'; export async function run( options: { inputFilePath: string | undefined, - outputFilePath: string | null, + outputFilePath: string, optimizeSpeed: boolean, verbose: boolean, processOpts: { stdio: [string, string, string] }, @@ -94,15 +94,16 @@ export async function run( // Make sure all the folders up to the output file exist, if not create them. // This mirrors elm make behavior. - const outputDirectory = path.dirname(program.output); + const outputDirectory = path.dirname(options.outputFilePath); if (!fs.existsSync(outputDirectory)) { fs.mkdirSync(outputDirectory, { recursive: true }); } - fs.writeFileSync(program.output, transformed); + fs.writeFileSync(options.outputFilePath, transformed); const fileName = path.basename(inputFilePath); log('Success!'); log(''); - log(` ${fileName} ───> ${program.output}`); + log(` ${fileName} ───> ${options.outputFilePath}`); log(''); + return options.outputFilePath; } }