Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Commit 33211bc

Browse files
authored
chore: improve system-test log format (#1921)
1 parent 178b481 commit 33211bc

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

system-test/test.kitchen.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,25 @@ let stagingDir: string;
3838
async function run(...params: Parameters<typeof spawn>) {
3939
const command = spawn(...params);
4040

41+
function stdout(str: string) {
42+
const prefix = '\n>>> STDOUT: ';
43+
console.log(prefix + str.replace(/\n/g, prefix));
44+
}
45+
46+
function stderr(str: string) {
47+
const prefix = '\n>>> STDERR: ';
48+
console.error(prefix + str.replace(/\n/g, prefix));
49+
}
50+
4151
await new Promise<void>((resolve, reject) => {
4252
// Unlike `exec`/`execFile`, this keeps the order of STDOUT/STDERR in case they were interweaved;
4353
// making it easier to debug and follow along.
44-
command.stdout?.on('data', console.log);
45-
command.stderr?.on('data', console.error);
54+
command.stdout?.setEncoding('utf8');
55+
command.stderr?.setEncoding('utf8');
56+
57+
command.stdout?.on('data', stdout);
58+
command.stderr?.on('data', stderr);
59+
4660
command.on('close', (code, signal) => {
4761
return code === 0 ? resolve() : reject({code, signal});
4862
});

0 commit comments

Comments
 (0)