Skip to content

Commit

Permalink
Fix verbose logs interleaving (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 15, 2023
1 parent 9a2b00f commit 37669f1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/verbose.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {writeFileSync} from 'node:fs';
import {debuglog} from 'node:util';
import process from 'node:process';

Expand All @@ -15,5 +16,7 @@ export const logCommand = (escapedCommand, {verbose}) => {
return;
}

process.stderr.write(`[${getTimestamp()}] ${escapedCommand}\n`);
// Write synchronously to ensure it is written before spawning the child process.
// This guarantees this line is written to `stderr` before the child process prints anything.
writeFileSync(process.stderr.fd, `[${getTimestamp()}] ${escapedCommand}\n`);
};

0 comments on commit 37669f1

Please sign in to comment.