Skip to content

Commit

Permalink
chore: interaction model generator can now also write to standard output
Browse files Browse the repository at this point in the history
  • Loading branch information
Govinda Raju authored and Shreyas-vgr committed Oct 21, 2020
1 parent 928e18c commit a03846f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/interactionModelGeneration/InteractionModelGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,20 @@ export class InteractionModelGenerator {
}

/**
* Build the interaction model and write to disk.
* Build the interaction model and write to disk or standard output.
*
* @param filename - Filename
* @param filename - Filename(optional)
*/
buildAndWrite(filename: string) {
buildAndWrite(filename?: string) {
const interactionModelJson: string = JSON.stringify(this.build(), null, 2);
const path: string = join(process.cwd(), filename);
fs.writeFileSync(path, interactionModelJson);
log.info(`Wrote interactionModel: ${path}`);
if (filename === undefined) {
process.stdout.write(interactionModelJson);
log.info('Wrote to standard output');
} else {
const path: string = join(process.cwd(), filename);
fs.writeFileSync(path, interactionModelJson);
log.info(`Wrote interactionModel: ${path}`);
}
}
}

Expand Down

0 comments on commit a03846f

Please sign in to comment.