diff --git a/src/interactionModelGeneration/InteractionModelGenerator.ts b/src/interactionModelGeneration/InteractionModelGenerator.ts index 3bc2741..9b77c2e 100644 --- a/src/interactionModelGeneration/InteractionModelGenerator.ts +++ b/src/interactionModelGeneration/InteractionModelGenerator.ts @@ -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}`); + } } }