Pass options from program

This commit is contained in:
Jeroen Engels 2021-10-01 17:59:14 +02:00
parent a775035631
commit 88d34d3a75

View File

@ -32,12 +32,11 @@ Give me an Elm file, I'll compile it behind the scenes using Elm 0.19.1, and the
// .option('--replacements <dir>', 'Replace stuff') // .option('--replacements <dir>', 'Replace stuff')
.parse(process.argv); .parse(process.argv);
async function run(inputFilePath: string | undefined) { async function run(inputFilePath: string | undefined, options: { output: string | null, optimizeSpeed: boolean }) {
const dirname = process.cwd(); const dirname = process.cwd();
let jsSource: string = ''; let jsSource: string = '';
let elmFilePath = undefined; let elmFilePath = undefined;
const options = program.opts();
const replacements = null; const replacements = null;
const o3Enabled = options.optimizeSpeed; const o3Enabled = options.optimizeSpeed;
@ -123,5 +122,5 @@ async function run(inputFilePath: string | undefined) {
} }
} }
const { output, optimizeSpeed } = program.opts();
run(program.args[0]).catch((e) => console.error(e)); run(program.args[0], { output, optimizeSpeed }).catch((e) => console.error(e));