-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket-patch
More file actions
executable file
·46 lines (42 loc) · 1.77 KB
/
socket-patch
File metadata and controls
executable file
·46 lines (42 loc) · 1.77 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
#!/usr/bin/env node
const { spawnSync } = require("child_process");
const path = require("path");
const PLATFORMS = {
"darwin arm64": ["@socketsecurity/socket-patch-darwin-arm64"],
"darwin x64": ["@socketsecurity/socket-patch-darwin-x64"],
"linux x64": ["@socketsecurity/socket-patch-linux-x64-gnu", "@socketsecurity/socket-patch-linux-x64-musl"],
"linux arm64": ["@socketsecurity/socket-patch-linux-arm64-gnu", "@socketsecurity/socket-patch-linux-arm64-musl"],
"linux arm": ["@socketsecurity/socket-patch-linux-arm-gnu", "@socketsecurity/socket-patch-linux-arm-musl"],
"linux ia32": ["@socketsecurity/socket-patch-linux-ia32-gnu", "@socketsecurity/socket-patch-linux-ia32-musl"],
"win32 x64": ["@socketsecurity/socket-patch-win32-x64"],
"win32 ia32": ["@socketsecurity/socket-patch-win32-ia32"],
"win32 arm64": ["@socketsecurity/socket-patch-win32-arm64"],
"android arm64": ["@socketsecurity/socket-patch-android-arm64"],
};
const key = `${process.platform} ${process.arch}`;
const candidates = PLATFORMS[key];
if (!candidates) {
console.error(`Unsupported platform: ${key}`);
process.exit(1);
}
const exe = process.platform === "win32" ? "socket-patch.exe" : "socket-patch";
let binPath;
for (const pkg of candidates) {
try {
const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
binPath = path.join(pkgDir, exe);
break;
} catch {}
}
if (!binPath) {
// Fallback: try local bin directory (for development or bundled installs)
const localBin = process.platform === "win32"
? `socket-patch-${key.replace(" ", "-")}.exe`
: `socket-patch-${key.replace(" ", "-")}`;
binPath = path.join(__dirname, localBin);
}
const result = spawnSync(binPath, process.argv.slice(2), {
stdio: "inherit",
env: process.env,
});
process.exit(result.status ?? 1);