@@ -86,9 +86,14 @@ export namespace Ripgrep {
86
86
export type End = z . infer < typeof End >
87
87
export type Summary = z . infer < typeof Summary >
88
88
const PLATFORM = {
89
- darwin : { platform : "apple-darwin" , extension : "tar.gz" } ,
90
- linux : { platform : "unknown-linux-musl" , extension : "tar.gz" } ,
91
- win32 : { platform : "pc-windows-msvc" , extension : "zip" } ,
89
+ "arm64-darwin" : { platform : "aarch64-apple-darwin" , extension : "tar.gz" } ,
90
+ "arm64-linux" : {
91
+ platform : "aarch64-unknown-linux-gnu" ,
92
+ extension : "tar.gz" ,
93
+ } ,
94
+ "x64-darwin" : { platform : "x86_64-apple-darwin" , extension : "tar.gz" } ,
95
+ "x64-linux" : { platform : "x86_64-unknown-linux-musl" , extension : "tar.gz" } ,
96
+ "x64-win32" : { platform : "x86_64-pc-windows-msvc" , extension : "zip" } ,
92
97
} as const
93
98
94
99
export const ExtractionFailedError = NamedError . create (
@@ -124,15 +129,13 @@ export namespace Ripgrep {
124
129
125
130
const file = Bun . file ( filepath )
126
131
if ( ! ( await file . exists ( ) ) ) {
127
- const archMap = { x64 : "x86_64" , arm64 : "aarch64" } as const
128
- const arch = archMap [ process . arch as keyof typeof archMap ] ?? process . arch
129
-
130
- const config = PLATFORM [ process . platform as keyof typeof PLATFORM ]
131
- if ( ! config )
132
- throw new UnsupportedPlatformError ( { platform : process . platform } )
132
+ const platformKey =
133
+ `${ process . arch } -${ process . platform } ` as keyof typeof PLATFORM
134
+ const config = PLATFORM [ platformKey ]
135
+ if ( ! config ) throw new UnsupportedPlatformError ( { platform : platformKey } )
133
136
134
137
const version = "14.1.1"
135
- const filename = `ripgrep-${ version } -${ arch } - ${ config . platform } .${ config . extension } `
138
+ const filename = `ripgrep-${ version } -${ config . platform } .${ config . extension } `
136
139
const url = `https://github.com/BurntSushi/ripgrep/releases/download/${ version } /${ filename } `
137
140
138
141
const response = await fetch ( url )
@@ -145,8 +148,8 @@ export namespace Ripgrep {
145
148
if ( config . extension === "tar.gz" ) {
146
149
const args = [ "tar" , "-xzf" , archivePath , "--strip-components=1" ]
147
150
148
- if ( process . platform === " darwin") args . push ( "--include=*/rg" )
149
- if ( process . platform === " linux") args . push ( "--wildcards" , "*/rg" )
151
+ if ( platformKey . endsWith ( "- darwin") ) args . push ( "--include=*/rg" )
152
+ if ( platformKey . endsWith ( "- linux") ) args . push ( "--wildcards" , "*/rg" )
150
153
151
154
const proc = Bun . spawn ( args , {
152
155
cwd : Global . Path . bin ,
@@ -177,7 +180,7 @@ export namespace Ripgrep {
177
180
} )
178
181
}
179
182
await fs . unlink ( archivePath )
180
- if ( process . platform !== " win32") await fs . chmod ( filepath , 0o755 )
183
+ if ( ! platformKey . endsWith ( "- win32") ) await fs . chmod ( filepath , 0o755 )
181
184
}
182
185
183
186
return {
0 commit comments