Skip to content

Commit d5381e2

Browse files
committed
Improve error logging stdout node #1094
1 parent 48b18ec commit d5381e2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

browser/e2e/tests/template.spec.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,29 @@ import fs from 'node:fs';
1313
import { spawn, type ChildProcess } from 'node:child_process';
1414
import path from 'node:path';
1515
import kill from 'kill-port';
16-
import { promisify } from 'util';
1716
import { log } from 'node:console';
1817

19-
const execAsync = promisify(exec);
18+
const execAsync = async (
19+
command: Parameters<typeof exec>[0],
20+
options?: Parameters<typeof exec>[1],
21+
) => {
22+
return new Promise((resolve, reject) => {
23+
exec(command, options, (err, stdout, stderr) => {
24+
console.log(stdout, stderr);
25+
26+
if (err) {
27+
reject(new Error(err.message));
28+
}
29+
30+
if (stderr) {
31+
reject(new Error(stderr.toString()));
32+
}
33+
34+
resolve(stdout.toString());
35+
});
36+
});
37+
};
38+
2039
const TEMPLATE_DIR_NAME = 'template-tests';
2140
// test.describe.configure({ mode: 'serial' });
2241

0 commit comments

Comments
 (0)