forked from webgpu/webgpu-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.js
78 lines (73 loc) · 2.07 KB
/
check.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* This is needed because FlexLayout gets errors (circular dependencies)
* and I could not figure out a way to suppress them.
*
* If you know how, please make a pull request! 🙏
*
* It works by building, capturing stderr, and checking for things that look
* like errors.
*/
import child_process from 'child_process';
import process from 'process';
export function execFile(exe, args) {
return new Promise((resolve, reject) => {
child_process.execFile(
exe,
args,
{
windowsHide: true,
},
(error, stdout, stderr) => {
if (error) {
reject({ error, stdout, stderr });
} else {
resolve({ stdout, stderr });
}
}
);
});
}
export function execFileWithLiveOutput(exe, args) {
return new Promise((resolve, reject) => {
const proc = child_process.execFile(
exe,
args,
{
// const proc = child_process.fork(exe, args, {
windowsHide: true,
env: {
...process.env,
ELECTRON_RUN_AS_NODE: 'true',
},
},
(error, stdout, stderr) => {
if (error) {
reject({ error, stdout, stderr });
} else {
resolve({ stdout, stderr });
}
}
);
if (proc.stdout) {
proc.stdout.on('data', data => {
console.log(data);
});
proc.stderr.on('data', data => {
console.error(data);
});
}
});
}
async function main() {
let success = false;
try {
const { stderr } = await execFileWithLiveOutput('./node_modules/.bin/rollup', ['-c']);
success = !/\.tsx{0,1}: \(\d+:\d+\)/.test(stderr);
} catch ({ stdout, stderr, error }) {
//
}
if (!success) {
throw new Error('failed to build without errors');
}
}
main();