forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrescript_postinstall.js
43 lines (36 loc) · 1.16 KB
/
rescript_postinstall.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
//@ts-check
const child_process = require("child_process");
const fs = require("fs");
const bsc_exe = require("./bin_path").bsc_exe;
const ninja_exe = require("./bin_path").ninja_exe;
function checkNinja() {
if (!fs.existsSync(ninja_exe)) {
throw new Error(
`No ninja binary found for this platform. ${ninja_exe} does not exist.`
);
}
try {
return String(child_process.execFileSync(ninja_exe, ["--version"])).trim();
} catch (e) {
throw new Error(
`Error getting ninja version. The ninja binary at ${ninja_exe} may not be compatible with this platform: ${e}`
);
}
}
function checkCompiler() {
if (!fs.existsSync(bsc_exe)) {
throw new Error(
`No ReScript compiler binary found for this platform. ${bsc_exe} does not exist.`
);
}
try {
return String(child_process.execFileSync(bsc_exe, ["-v"])).trim();
} catch (e) {
throw new Error(
`Error getting ReScript compiler version. The compiler binary at ${bsc_exe} may not be compatible with this platform: ${e}`
);
}
}
var ninjaVersion = checkNinja();
var compilerVersion = checkCompiler();
console.log(`${compilerVersion} (ninja ${ninjaVersion})`);