Skip to content

Commit 8fe0b40

Browse files
committed
compute realpath of binaries as needed
1 parent 636c929 commit 8fe0b40

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

cli/common/bins.js

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
import * as fs from "node:fs";
4+
35
/**
46
* @typedef {{
57
* binDir: string,
@@ -27,15 +29,28 @@ try {
2729
throw new Error(`Platform ${target} is not supported!`);
2830
}
2931

32+
const binPaths = mod.binPaths;
33+
// Compiler use symbolic links in the development process
34+
if (fs.lstatSync(binPaths.rescript_exe).isSymbolicLink()) {
35+
for (const [key, binPath] of Object.entries(binPaths)) {
36+
try {
37+
binPaths[/** @type {keyof BinaryPaths} */(key)] = fs.realpathSync(binPath);
38+
} catch {
39+
// Cannot populate the realpath of a binary, some tests may fails.
40+
//
41+
// But we don't report error here,
42+
// so pass even some binaries are not built yet.
43+
}
44+
}
45+
}
46+
47+
export const platformDir = mod.binDir;
3048
export const {
31-
binDir: platformDir,
32-
binPaths: {
33-
bsb_helper_exe,
34-
bsc_exe,
35-
ninja_exe,
36-
rescript_editor_analysis_exe,
37-
rescript_tools_exe,
38-
rescript_exe,
39-
rewatch_exe,
40-
},
41-
} = mod;
49+
bsb_helper_exe,
50+
bsc_exe,
51+
ninja_exe,
52+
rescript_editor_analysis_exe,
53+
rescript_tools_exe,
54+
rescript_exe,
55+
rewatch_exe,
56+
} = binPaths;

0 commit comments

Comments
 (0)