Skip to content

Commit

Permalink
Merge pull request #2094 from embroider-build/command-watcher-logs
Browse files Browse the repository at this point in the history
make CommandWatcher dump logs at shutdown() when a command has failed
  • Loading branch information
mansona authored Sep 3, 2024
2 parents bd04b35 + 9fa39a0 commit e1733ef
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/scenarios/helpers/command-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default class CommandWatcher {

async shutdown(): Promise<void> {
if (this.exitCode != null) {
this.maybeEmitLogs();
return;
}

Expand All @@ -119,6 +120,14 @@ export default class CommandWatcher {
});

await this.waitForExit();
this.maybeEmitLogs();
}

private maybeEmitLogs() {
if (this.exitCode !== 0) {
console.error(`CommandWatcher saw non-zero exit, dumping logs:`);
console.error(this.lines.join('\n'));
}
}

async waitForExit(): Promise<number> {
Expand Down

0 comments on commit e1733ef

Please sign in to comment.