| 22 | const binaryDir = path.join(__dirname, 'vendor', 'ripgrep') |
| 23 | |
| 24 | function getPlatformMapping() { |
| 25 | const arch = process.arch |
| 26 | const platform = process.platform |
| 27 | if (platform === 'darwin') { |
| 28 | if (arch === 'arm64') return { target: 'aarch64-apple-darwin', ext: 'tar.gz' } |
| 29 | if (arch === 'x64') return { target: 'x86_64-apple-darwin', ext: 'tar.gz' } |
| 30 | throw new Error(`Unsupported macOS arch: ${arch}`) |
| 31 | } |
| 32 | if (platform === 'win32') { |
| 33 | if (arch === 'x64') return { target: 'x86_64-pc-windows-msvc', ext: 'zip' } |
| 34 | if (arch === 'arm64') return { target: 'aarch64-pc-windows-msvc', ext: 'zip' } |
| 35 | throw new Error(`Unsupported Windows arch: ${arch}`) |
| 36 | } |
| 37 | if (platform === 'linux') { |
| 38 | const isMusl = detectMusl() |
| 39 | if (arch === 'x64') return { target: 'x86_64-unknown-linux-musl', ext: 'tar.gz' } |
| 40 | if (arch === 'arm64') { |
| 41 | return isMusl |
| 42 | ? { target: 'aarch64-unknown-linux-musl', ext: 'tar.gz' } |
| 43 | : { target: 'aarch64-unknown-linux-gnu', ext: 'tar.gz' } |
| 44 | } |
| 45 | throw new Error(`Unsupported Linux arch: ${arch}`) |
| 46 | } |
| 47 | throw new Error(`Unsupported platform: ${platform}`) |
| 48 | } |
| 49 | |
| 50 | function detectMusl() { |
| 51 | const muslArch = process.arch === 'x64' ? 'x86_64' : 'aarch64' |