Skip to content

Commit a03846f

Browse files
Govinda RajuShreyas-vgr
authored andcommitted
chore: interaction model generator can now also write to standard output
1 parent 928e18c commit a03846f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/interactionModelGeneration/InteractionModelGenerator.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,20 @@ export class InteractionModelGenerator {
293293
}
294294

295295
/**
296-
* Build the interaction model and write to disk.
296+
* Build the interaction model and write to disk or standard output.
297297
*
298-
* @param filename - Filename
298+
* @param filename - Filename(optional)
299299
*/
300-
buildAndWrite(filename: string) {
300+
buildAndWrite(filename?: string) {
301301
const interactionModelJson: string = JSON.stringify(this.build(), null, 2);
302-
const path: string = join(process.cwd(), filename);
303-
fs.writeFileSync(path, interactionModelJson);
304-
log.info(`Wrote interactionModel: ${path}`);
302+
if (filename === undefined) {
303+
process.stdout.write(interactionModelJson);
304+
log.info('Wrote to standard output');
305+
} else {
306+
const path: string = join(process.cwd(), filename);
307+
fs.writeFileSync(path, interactionModelJson);
308+
log.info(`Wrote interactionModel: ${path}`);
309+
}
305310
}
306311
}
307312

0 commit comments

Comments
 (0)