Skip to content

Commit 6226bf1

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

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cli/common/bins.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,28 @@
55
*/
66

77
const target = `${process.platform}-${process.arch}`;
8+
const binPackageName = `@rescript/${target}`;
9+
10+
const supportedPlatforms = [
11+
"darwin-arm64",
12+
"darwin-x64",
13+
"linux-arm64",
14+
"linux-x64",
15+
"win32-x64",
16+
];
817

918
/** @type {BinaryModuleExports} */
1019
let mod;
11-
try {
12-
mod = await import(`@rescript/${target}`);
13-
} catch {
20+
21+
if (supportedPlatforms.includes(target)) {
22+
try {
23+
mod = await import(binPackageName);
24+
} catch {
25+
throw new Error(
26+
`Package ${binPackageName} not found. Make sure the rescript package is installed correctly.`,
27+
);
28+
}
29+
} else {
1430
throw new Error(`Platform ${target} is not supported!`);
1531
}
1632

0 commit comments

Comments
 (0)