Skip to content

Commit 530c165

Browse files
committed
fix: catch execFile errors
1 parent 2bd53d5 commit 530c165

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/node/lib.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ export async function minifyFiles(files: readonly string[], hasComment = true):
3434
*/
3535
export function spawnMinijson(args: string[]): Promise<string> {
3636
return new Promise<string>((resolve, reject) => {
37-
execFile(minijsonBin, args, (err, stdout, stderr) => {
38-
console.error(stderr)
39-
console.log(stdout)
37+
try {
38+
execFile(minijsonBin, args, (err, stdout, stderr) => {
39+
console.error(stderr)
40+
console.log(stdout)
4041

41-
if (err) {
42-
reject(err)
43-
}
44-
if (stderr !== "") {
45-
reject(stderr)
46-
}
47-
resolve(stdout)
48-
})
42+
if (err) {
43+
reject(err)
44+
}
45+
if (stderr !== "") {
46+
reject(stderr)
47+
}
48+
resolve(stdout)
49+
})
50+
} catch (execErr) {
51+
reject(execErr)
52+
}
4953
})
5054
}
5155

0 commit comments

Comments
 (0)