Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/downloadRipGrep.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { mkdir, createWriteStream, move } = fsExtra
const __dirname = dirname(fileURLToPath(import.meta.url))

const REPOSITORY = `microsoft/ripgrep-prebuilt`
const VERSION = process.env.RIPGREP_VERSION || 'v13.0.0-10'
const VERSION = process.env.RIPGREP_VERSION || 'v15.0.0'
const BIN_PATH = join(__dirname, '../bin')

const getTarget = () => {
Expand Down Expand Up @@ -123,7 +123,9 @@ export const downloadRipGrep = async (overrideBinPath) => {
}
}
const target = getTarget()
const baseUrl = process.env.RIPGREP_PREBUILT_BINARIES_MIRROR || `https://github.com/${REPOSITORY}/releases/download`
const baseUrl =
process.env.RIPGREP_PREBUILT_BINARIES_MIRROR ||
`https://github.com/${REPOSITORY}/releases/download`
const url = `${baseUrl}/${VERSION}/ripgrep-${VERSION}-${target}`
const downloadPath = `${xdgCache}/vscode-ripgrep/ripgrep-${VERSION}-${target}`
const binPath = overrideBinPath ?? BIN_PATH
Expand Down
14 changes: 7 additions & 7 deletions test/downloadRipGrep.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('downloadRipGrep should handle network error', async () => {
// Simulate a network failure so pipeline rejects
nock('https://github.com')
.get(
'/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz',
'/microsoft/ripgrep-prebuilt/releases/download/v15.0.0/ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz',
)
.replyWithError('simulated error')

Expand All @@ -69,7 +69,7 @@ test('downloadRipGrep should successfully download and extract file', async () =
// Intercept the GitHub asset request with a simple 200 body
const scope = nock('https://github.com')
.get(
'/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz',
'/microsoft/ripgrep-prebuilt/releases/download/v15.0.0/ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz',
)
.reply(200, 'mock-tar-gz-content', {
'Content-Type': 'application/gzip',
Expand All @@ -86,7 +86,7 @@ test('downloadRipGrep should successfully download and extract file', async () =
expect(tarArgs[0]).toBe('xvf')
expect(normalize(tarArgs[1])).toContain(
normalize(
`${tempCacheDir}/vscode-ripgrep/ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz`,
`${tempCacheDir}/vscode-ripgrep/ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz`,
),
)
expect(tarArgs[2]).toBe('-C')
Expand All @@ -99,7 +99,7 @@ test('downloadRipGrep should use cached file when it exists', async () => {
mkdirSync(cachedDir, { recursive: true })
const cachedFile = join(
cachedDir,
'ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz',
'ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz',
)
writeFileSync(cachedFile, 'already-downloaded')

Expand All @@ -126,16 +126,16 @@ test('downloadFile should handle download errors', async () => {
// Make the stream fail to ensure pipeline rejects
nock('https://github.com')
.get(
'/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz',
'/microsoft/ripgrep-prebuilt/releases/download/v15.0.0/ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz',
)
.replyWithError('simulated error')

await expect(
downloadFile(
'https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz',
'https://github.com/microsoft/ripgrep-prebuilt/releases/download/v15.0.0/ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz',
join(tmpdir(), 'test.tar.gz'),
),
).rejects.toThrow(
`Failed to download \"https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-unknown-linux-musl.tar.gz\": simulated error`,
`Failed to download \"https://github.com/microsoft/ripgrep-prebuilt/releases/download/v15.0.0/ripgrep-v15.0.0-x86_64-unknown-linux-musl.tar.gz\": simulated error`,
)
})