chore: rm double conditional
This commit is contained in:
parent
e29120317f
commit
769c97af08
1 changed files with 22 additions and 24 deletions
|
|
@ -162,34 +162,32 @@ export namespace Ripgrep {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (config.extension === "zip") {
|
if (config.extension === "zip") {
|
||||||
if (config.extension === "zip") {
|
const zipFileReader = new ZipReader(new BlobReader(new Blob([await Bun.file(archivePath).arrayBuffer()])))
|
||||||
const zipFileReader = new ZipReader(new BlobReader(new Blob([await Bun.file(archivePath).arrayBuffer()])))
|
const entries = await zipFileReader.getEntries()
|
||||||
const entries = await zipFileReader.getEntries()
|
let rgEntry: any
|
||||||
let rgEntry: any
|
for (const entry of entries) {
|
||||||
for (const entry of entries) {
|
if (entry.filename.endsWith("rg.exe")) {
|
||||||
if (entry.filename.endsWith("rg.exe")) {
|
rgEntry = entry
|
||||||
rgEntry = entry
|
break
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rgEntry) {
|
|
||||||
throw new ExtractionFailedError({
|
|
||||||
filepath: archivePath,
|
|
||||||
stderr: "rg.exe not found in zip archive",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const rgBlob = await rgEntry.getData(new BlobWriter())
|
|
||||||
if (!rgBlob) {
|
|
||||||
throw new ExtractionFailedError({
|
|
||||||
filepath: archivePath,
|
|
||||||
stderr: "Failed to extract rg.exe from zip archive",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await Bun.write(filepath, await rgBlob.arrayBuffer())
|
|
||||||
await zipFileReader.close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!rgEntry) {
|
||||||
|
throw new ExtractionFailedError({
|
||||||
|
filepath: archivePath,
|
||||||
|
stderr: "rg.exe not found in zip archive",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const rgBlob = await rgEntry.getData(new BlobWriter())
|
||||||
|
if (!rgBlob) {
|
||||||
|
throw new ExtractionFailedError({
|
||||||
|
filepath: archivePath,
|
||||||
|
stderr: "Failed to extract rg.exe from zip archive",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await Bun.write(filepath, await rgBlob.arrayBuffer())
|
||||||
|
await zipFileReader.close()
|
||||||
}
|
}
|
||||||
await fs.unlink(archivePath)
|
await fs.unlink(archivePath)
|
||||||
if (!platformKey.endsWith("-win32")) await fs.chmod(filepath, 0o755)
|
if (!platformKey.endsWith("-win32")) await fs.chmod(filepath, 0o755)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue