Skip to content

Commit 236dd45

Browse files
committed
add more checking logic
1 parent 389c4a8 commit 236dd45

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

scripts/prebuilt.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,40 @@ var root_config = { cwd: root, stdio: [0, 1, 2], encoding: "utf8" };
99

1010
var ocamlVersion = require("./buildocaml.js").getVersionPrefix();
1111
var fs = require("fs");
12+
var package_config = require(path.join(__dirname, "..", "package.json"));
13+
var bsVersion = fs.readFileSync(
14+
path.join(__dirname, "..", "jscomp", "common", "bs_version.ml"),
15+
"utf-8"
16+
);
17+
/**
18+
*
19+
* @param {string} bsVersion
20+
* @param {string} version
21+
*/
22+
function verifyVersion(bsVersion, version) {
23+
try {
24+
let [major, minor] = bsVersion
25+
.split("\n")
26+
.find((x) => x.startsWith("let version = "))
27+
.split("=")[1]
28+
.trim()
29+
.slice(1, -1)
30+
.split(".");
31+
let [specifiedMajor, specifiedMinor] = version.split(".");
32+
console.log(
33+
`package.json ${specifiedMajor}.${specifiedMinor} vs ABI : ${major}.${minor}`
34+
);
35+
return major === specifiedMajor && minor === specifiedMinor;
36+
} catch (e) {
37+
return false;
38+
}
39+
}
40+
var assert = require("assert");
41+
42+
assert(verifyVersion(bsVersion, package_config.version));
1243

13-
function isHostPlatform(){
14-
return process.platform === "darwin" || process.platform === "linux"
44+
function isHostPlatform() {
45+
return process.platform === "darwin" || process.platform === "linux";
1546
}
1647
function rebuild() {
1748
cp.execSync(`node ${path.join(__dirname, "ninja.js")} cleanbuild`, {
@@ -53,7 +84,7 @@ if (!is_windows) {
5384
}
5485

5586
function createOCamlTar() {
56-
if (isHostPlatform()) {
87+
if (isHostPlatform()) {
5788
require("./installUtils.js").install();
5889
console.log(`status in ocaml submodule:`);
5990
cp.execSync(`git -C ocaml status -uno`, { cwd: root, stdio: [0, 1, 2] });

0 commit comments

Comments
 (0)