diff --git a/cli/morphir-elm-make.js b/cli/morphir-elm-make.js index a1bcc47e5..45359e2fd 100644 --- a/cli/morphir-elm-make.js +++ b/cli/morphir-elm-make.js @@ -18,6 +18,7 @@ program .option('-o, --output ', 'Target file location where the Morphir IR will be saved.', 'morphir-ir.json') .option('-t, --types-only', 'Only include type information in the IR, no values.', false) .option('-f, --fallback-cli', 'Use old cli make function.', false) + .option('-i, --indent-json', 'Use indentation in the generated JSON file.', false) .parse(process.argv) const programOptions = program.opts() @@ -43,7 +44,7 @@ function make(projectDir, opts) { cli.make(projectDir, opts) .then((packageDef) => { console.log(`Writing file ${opts.output}.`) - cli.writeFile(opts.output, JSON.stringify(packageDef, null, 4)) + cli.writeFile(opts.output, JSON.stringify(packageDef, null, opts.indentJson ? 4 : 0)) .then(() => { console.log('Done.') }) diff --git a/cli2/cli.ts b/cli2/cli.ts index e711097a2..78533df97 100644 --- a/cli2/cli.ts +++ b/cli2/cli.ts @@ -135,7 +135,7 @@ async function buildFromScratch( if (err) { reject(err); } else { - resolve(JSON.stringify(ok, null, 4)); + resolve(JSON.stringify(ok, null, options.indentJson ? 4 : 0)); } }); @@ -176,7 +176,7 @@ async function buildIncrementally( if (err) { reject(err); } else { - resolve(JSON.stringify(ok, null, 4)); + resolve(JSON.stringify(ok, null, options.indentJson ? 4 : 0)); } }); @@ -519,8 +519,8 @@ async function testCoverage( // output path const output = path.join(path.resolve(outputPath), "morphir-test-coverage.json") - - return new Promise((resolve, reject) => { + + return new Promise((resolve, reject) => { worker.ports.testCoverageResult.subscribe(([err, data]: any) => { if (err) { reject(err) @@ -531,7 +531,7 @@ async function testCoverage( }) // send files through port - worker.ports.testCoverage.send([morphirIRJson,morphirTestJson]) + worker.ports.testCoverage.send([morphirIRJson, morphirTestJson]) }); } diff --git a/cli2/morphir-make.ts b/cli2/morphir-make.ts index 9a34c3f01..0ac649a64 100644 --- a/cli2/morphir-make.ts +++ b/cli2/morphir-make.ts @@ -15,9 +15,10 @@ program .option('-p, --project-dir ', 'Root directory of the project where morphir.json is located.', '.') .option('-o, --output ', 'Target file location where the Morphir IR will be saved.', 'morphir-ir.json') .option('-t, --types-only', 'Only include type information in the IR, no values.', false) + .option('-i, --indent-json', 'Use indentation in the generated JSON file.', false) .parse(process.argv) const dirAndOutput = program.opts() // run make -make( dirAndOutput.projectDir, dirAndOutput ) \ No newline at end of file +make(dirAndOutput.projectDir, dirAndOutput) \ No newline at end of file