@mrwinston/fibers 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ // npm install hook: use a prebuilt binary for this platform and Node ABI if
2
+ // the package ships one, otherwise compile from source with node-gyp.
3
+
4
+ import { spawnSync } from "node:child_process";
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+
8
+ const root = path.join(import.meta.dirname, "..");
9
+ const supported = ["linux-x64"];
10
+ const target = `${process.platform}-${process.arch}`;
11
+
12
+ if (!supported.includes(target)) {
13
+ console.error(
14
+ `fibers: only ${supported.join(" and ")} is supported (got ${target})`,
15
+ );
16
+ process.exit(1);
17
+ }
18
+
19
+ const prebuilt = path.join(
20
+ root,
21
+ "prebuilds",
22
+ target,
23
+ `node-${process.versions.modules}`,
24
+ "fibers.node",
25
+ );
26
+
27
+ if (fs.existsSync(prebuilt)) {
28
+ process.exit(0);
29
+ }
30
+
31
+ console.log(
32
+ `fibers: no prebuilt binary for ${target}, Node ${process.version} (ABI ${process.versions.modules}); building from source`,
33
+ );
34
+
35
+ const gyp = process.env.npm_config_node_gyp;
36
+ const result = gyp
37
+ ? spawnSync(process.execPath, [gyp, "rebuild"], {
38
+ cwd: root,
39
+ stdio: "inherit",
40
+ })
41
+ : spawnSync("npx", ["node-gyp", "rebuild"], {
42
+ cwd: root,
43
+ stdio: "inherit",
44
+ shell: process.platform === "win32",
45
+ });
46
+
47
+ process.exit(result.status ?? 1);