Skip to content

Commit

Permalink
Merge pull request #1098 from AttilaMihaly/main
Browse files Browse the repository at this point in the history
Add option for indentation and make no indentation the default.
  • Loading branch information
AttilaMihaly authored Sep 5, 2023
2 parents 50bdb76 + 13d0142 commit 3b14da5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cli/morphir-elm-make.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ program
.option('-o, --output <path>', '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()
Expand All @@ -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.')
})
Expand Down
10 changes: 5 additions & 5 deletions cli2/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
});

Expand Down Expand Up @@ -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));
}
});

Expand Down Expand Up @@ -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)
Expand All @@ -531,7 +531,7 @@ async function testCoverage(
})

// send files through port
worker.ports.testCoverage.send([morphirIRJson,morphirTestJson])
worker.ports.testCoverage.send([morphirIRJson, morphirTestJson])
});
}

Expand Down
3 changes: 2 additions & 1 deletion cli2/morphir-make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ program
.option('-p, --project-dir <path>', 'Root directory of the project where morphir.json is located.', '.')
.option('-o, --output <path>', '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 )
make(dirAndOutput.projectDir, dirAndOutput)

0 comments on commit 3b14da5

Please sign in to comment.