Skip to content

Commit a6d3a7c

Browse files
authored
Prepare bin_path logic for more architectures (rescript-lang#5932)
1 parent 8d9eb92 commit a6d3a7c

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

bsc

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22
"use strict";
33

44
var child_process = require("child_process");
5-
var path = require("path");
6-
var exe = path.join(
7-
__dirname,
8-
process.platform === "darwin" && process.arch === "arm64"
9-
? process.platform + process.arch
10-
: process.platform,
11-
"bsc.exe"
12-
);
5+
var bsc_exe = require("./scripts/bin_path").bsc_exe;
6+
137
var delegate_args = process.argv.slice(2);
148

159
try {
16-
child_process.execFileSync(exe, delegate_args, { stdio: "inherit" });
10+
child_process.execFileSync(bsc_exe, delegate_args, { stdio: "inherit" });
1711
} catch (e) {
1812
if (e.code === "ENOENT") {
1913
console.error(String(e));

scripts/bin_path.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ var path = require("path");
44

55
/**
66
* @type{string}
7+
*
8+
* For compatibility reasons, if the architecture is x64, omit it from the bin directory name.
9+
* So we'll have "darwin", "linux" and "win32" for x64 arch,
10+
* but "darwinarm64" and "linuxarm64" for arm64 arch.
711
*/
812
var binDirName =
9-
process.platform === "darwin" && process.arch === "arm64"
10-
? process.platform + process.arch
11-
: process.platform;
13+
process.arch === "x64" ? process.platform : process.platform + process.arch;
1214

1315
/**
1416
*

0 commit comments

Comments
 (0)