Skip to content

Commit

Permalink
fix: truncated 'cdk diff' output in pipes
Browse files Browse the repository at this point in the history
We are force-exiting the process with `process.exit(1)`, which may leave
some `stdout` output unflushed. This is especially visible when doing
`cdk diff | tee diff.txt`, if there is a large diff. The output will
be truncated halfway through.

The correct solution is to set the exit code and let NodeJS terminate
itself gracefully when all output has been flushed.
  • Loading branch information
rix0rrr authored Feb 10, 2020
2 parents bc0fe14 + cac5150 commit aba1485
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ initCommandLine()
if (typeof value === 'string') {
data(value);
} else if (typeof value === 'number') {
process.exit(value);
process.exitCode = value;
}
})
.catch(err => {
error(err.message);
debug(err.stack);
process.exit(1);
process.exitCode = 1;
});

0 comments on commit aba1485

Please sign in to comment.