Skip to content

Commit a7f9a8e

Browse files
committed
Better error message if platform binaries package is not found
1 parent 76f9e00 commit a7f9a8e

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

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)