Skip to content

Commit bb06bbb

Browse files
author
Bart Schuurmans
authored
scripts/ciTest.js: catch exceptions from main (#5193)
In recent Node.js versions, an uncaught exception becomes an UnhandledPromiseRejection and that makes the actual error hard/impossible to find: https://app.circleci.com/pipelines/github/rescript-lang/rescript-compiler/3637/workflows/928d0272-43fe-4ac6-b981-114bdf3c5355/jobs/3759
1 parent ff3946c commit bb06bbb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

scripts/ciTest.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ts-check
22
var cp = require("child_process");
3-
43
var path = require("path");
4+
var fs = require("fs");
55

66
var installGlobal = false;
77
var ounitTest = false;
@@ -41,8 +41,6 @@ if (all) {
4141
bsbTest = true;
4242
}
4343

44-
var fs = require("fs");
45-
4644
function init() {
4745
var vendorOCamlPath = path.join(
4846
__dirname,
@@ -61,9 +59,7 @@ function init() {
6159
}
6260
}
6361

64-
function main() {
65-
init();
66-
62+
function runTests() {
6763
// when binary was prebuilt, there can be no ocaml installation
6864
// var output =
6965
// cp.execSync('which ocaml', { encoding: 'ascii' })
@@ -156,4 +152,13 @@ function main() {
156152
}
157153
}
158154

155+
function main() {
156+
try {
157+
init();
158+
runTests();
159+
} catch (err) {
160+
console.error(err);
161+
process.exit(2);
162+
}
163+
}
159164
main();

0 commit comments

Comments
 (0)