@@ -3,31 +3,35 @@ const { spawnSync } = require("child_process");
33const path = require ( "path" ) ;
44
55const PLATFORMS = {
6- "darwin arm64" : "@socketsecurity/socket-patch-darwin-arm64" ,
7- "darwin x64" : "@socketsecurity/socket-patch-darwin-x64" ,
8- "linux x64" : "@socketsecurity/socket-patch-linux-x64" ,
9- "linux arm64" : "@socketsecurity/socket-patch-linux-arm64" ,
10- "linux arm" : "@socketsecurity/socket-patch-linux-arm" ,
11- "linux ia32" : "@socketsecurity/socket-patch-linux-ia32" ,
12- "win32 x64" : "@socketsecurity/socket-patch-win32-x64" ,
13- "win32 ia32" : "@socketsecurity/socket-patch-win32-ia32" ,
14- "win32 arm64" : "@socketsecurity/socket-patch-win32-arm64" ,
15- "android arm64" : "@socketsecurity/socket-patch-android-arm64" ,
6+ "darwin arm64" : [ "@socketsecurity/socket-patch-darwin-arm64" ] ,
7+ "darwin x64" : [ "@socketsecurity/socket-patch-darwin-x64" ] ,
8+ "linux x64" : [ "@socketsecurity/socket-patch-linux-x64-gnu" , "@socketsecurity/socket-patch-linux-x64-musl" ] ,
9+ "linux arm64" : [ "@socketsecurity/socket-patch-linux-arm64-gnu" , "@socketsecurity/socket-patch-linux-arm64-musl" ] ,
10+ "linux arm" : [ "@socketsecurity/socket-patch-linux-arm-gnu" , "@socketsecurity/socket-patch-linux-arm-musl" ] ,
11+ "linux ia32" : [ "@socketsecurity/socket-patch-linux-ia32-gnu" , "@socketsecurity/socket-patch-linux-ia32-musl" ] ,
12+ "win32 x64" : [ "@socketsecurity/socket-patch-win32-x64" ] ,
13+ "win32 ia32" : [ "@socketsecurity/socket-patch-win32-ia32" ] ,
14+ "win32 arm64" : [ "@socketsecurity/socket-patch-win32-arm64" ] ,
15+ "android arm64" : [ "@socketsecurity/socket-patch-android-arm64" ] ,
1616} ;
1717
1818const key = `${ process . platform } ${ process . arch } ` ;
19- const pkg = PLATFORMS [ key ] ;
20- if ( ! pkg ) {
19+ const candidates = PLATFORMS [ key ] ;
20+ if ( ! candidates ) {
2121 console . error ( `Unsupported platform: ${ key } ` ) ;
2222 process . exit ( 1 ) ;
2323}
2424
2525const exe = process . platform === "win32" ? "socket-patch.exe" : "socket-patch" ;
2626let binPath ;
27- try {
28- const pkgDir = path . dirname ( require . resolve ( `${ pkg } /package.json` ) ) ;
29- binPath = path . join ( pkgDir , exe ) ;
30- } catch {
27+ for ( const pkg of candidates ) {
28+ try {
29+ const pkgDir = path . dirname ( require . resolve ( `${ pkg } /package.json` ) ) ;
30+ binPath = path . join ( pkgDir , exe ) ;
31+ break ;
32+ } catch { }
33+ }
34+ if ( ! binPath ) {
3135 // Fallback: try local bin directory (for development or bundled installs)
3236 const localBin = process . platform === "win32"
3337 ? `socket-patch-${ key . replace ( " " , "-" ) } .exe`
0 commit comments