Skip to content

Commit 59c41fc

Browse files
committed
compute realpath of binaries as needed
1 parent 636c929 commit 59c41fc

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

cli/common/bins.js

+27-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,29 @@ 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)] =
38+
fs.realpathSync(binPath);
39+
} catch {
40+
// Cannot populate the realpath of a binary, some tests may fails.
41+
//
42+
// But we don't report error here,
43+
// so pass even some binaries are not built yet.
44+
}
45+
}
46+
}
47+
48+
export const platformDir = mod.binDir;
3049
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;
50+
bsb_helper_exe,
51+
bsc_exe,
52+
ninja_exe,
53+
rescript_editor_analysis_exe,
54+
rescript_tools_exe,
55+
rescript_exe,
56+
rewatch_exe,
57+
} = binPaths;

0 commit comments

Comments
 (0)