-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathpostinstall.mjs
More file actions
59 lines (49 loc) · 1.38 KB
/
postinstall.mjs
File metadata and controls
59 lines (49 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// postinstall.mjs
// Runs after npm install to verify platform binary is available
import { createRequire } from "node:module";
import { getPlatformPackageCandidates, getBinaryPath } from "./bin/platform.js";
const require = createRequire(import.meta.url);
/**
* Detect libc family on Linux
*/
function getLibcFamily() {
if (process.platform !== "linux") {
return undefined;
}
try {
const detectLibc = require("detect-libc");
return detectLibc.familySync();
} catch {
return null;
}
}
function main() {
const { platform, arch } = process;
const libcFamily = getLibcFamily();
try {
const packageCandidates = getPlatformPackageCandidates({
platform,
arch,
libcFamily,
});
const resolvedPackage = packageCandidates.find((pkg) => {
try {
require.resolve(getBinaryPath(pkg, platform));
return true;
} catch {
return false;
}
});
if (!resolvedPackage) {
throw new Error(
`No platform binary package installed. Tried: ${packageCandidates.join(", ")}`
);
}
console.log(`✓ oh-my-opencode binary installed for ${platform}-${arch} (${resolvedPackage})`);
} catch (error) {
console.warn(`⚠ oh-my-opencode: ${error.message}`);
console.warn(` The CLI may not work on this platform.`);
// Don't fail installation - let user try anyway
}
}
main();