mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-25 22:50:42 +03:00
Return the outputFilePath and require it in the lib
This commit is contained in:
parent
908cec2fee
commit
ac3d1349af
@ -2,7 +2,7 @@ import * as Run from './run';
|
|||||||
|
|
||||||
export async function run(options: {
|
export async function run(options: {
|
||||||
inputFilePath: string | undefined,
|
inputFilePath: string | undefined,
|
||||||
outputFilePath: string | null,
|
outputFilePath: string,
|
||||||
optimizeSpeed: boolean,
|
optimizeSpeed: boolean,
|
||||||
processOpts: {
|
processOpts: {
|
||||||
stdio: [string, string, string],
|
stdio: [string, string, string],
|
||||||
|
@ -12,7 +12,7 @@ import * as fs from 'fs';
|
|||||||
export async function run(
|
export async function run(
|
||||||
options: {
|
options: {
|
||||||
inputFilePath: string | undefined,
|
inputFilePath: string | undefined,
|
||||||
outputFilePath: string | null,
|
outputFilePath: string,
|
||||||
optimizeSpeed: boolean,
|
optimizeSpeed: boolean,
|
||||||
verbose: boolean,
|
verbose: boolean,
|
||||||
processOpts: { stdio: [string, string, string] },
|
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.
|
// Make sure all the folders up to the output file exist, if not create them.
|
||||||
// This mirrors elm make behavior.
|
// This mirrors elm make behavior.
|
||||||
const outputDirectory = path.dirname(program.output);
|
const outputDirectory = path.dirname(options.outputFilePath);
|
||||||
if (!fs.existsSync(outputDirectory)) {
|
if (!fs.existsSync(outputDirectory)) {
|
||||||
fs.mkdirSync(outputDirectory, { recursive: true });
|
fs.mkdirSync(outputDirectory, { recursive: true });
|
||||||
}
|
}
|
||||||
fs.writeFileSync(program.output, transformed);
|
fs.writeFileSync(options.outputFilePath, transformed);
|
||||||
const fileName = path.basename(inputFilePath);
|
const fileName = path.basename(inputFilePath);
|
||||||
log('Success!');
|
log('Success!');
|
||||||
log('');
|
log('');
|
||||||
log(` ${fileName} ───> ${program.output}`);
|
log(` ${fileName} ───> ${options.outputFilePath}`);
|
||||||
log('');
|
log('');
|
||||||
|
return options.outputFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user