Skip to content

Commit 812d07e

Browse files
authored
Better error message if platform binaries package is not found (#7698)
1 parent 663bfd0 commit 812d07e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#### :nail_care: Polish
2424

2525
- Configuration fields `bs-dependencies`, `bs-dev-dependencies` and `bsc-flags` are now deprecated in favor of `dependencies`, `dev-dependencies` and `compiler-flags`. https://github.com/rescript-lang/rescript/pull/7658
26+
- Better error message if platform binaries package is not found. https://github.com/rescript-lang/rescript/pull/7698
2627

2728
#### :house: Internal
2829

cli/common/bins.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,28 @@
66

77
const target = `${process.platform}-${process.arch}`;
88

9+
const supportedPlatforms = [
10+
"darwin-arm64",
11+
"darwin-x64",
12+
"linux-arm64",
13+
"linux-x64",
14+
"win32-x64",
15+
];
16+
917
/** @type {BinaryModuleExports} */
1018
let mod;
11-
try {
12-
mod = await import(`@rescript/${target}`);
13-
} catch {
19+
20+
if (supportedPlatforms.includes(target)) {
21+
const binPackageName = `@rescript/${target}`;
22+
23+
try {
24+
mod = await import(binPackageName);
25+
} catch {
26+
throw new Error(
27+
`Package ${binPackageName} not found. Make sure the rescript package is installed correctly.`,
28+
);
29+
}
30+
} else {
1431
throw new Error(`Platform ${target} is not supported!`);
1532
}
1633

0 commit comments

Comments
 (0)