fix: faster zip extraction on Windows via 7z

This commit is contained in:
Amin Yahyaabadi 2024-09-10 01:12:30 -07:00
parent 90d7a9bccf
commit 01e15aee5c
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
5 changed files with 11 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -90,13 +90,19 @@ export function extractExe(file: string, dest: string) {
/// Extract Zip using unzip or 7z
export async function extractZip(file: string, dest: string) {
// if unzip is available use it
// prefer 7z if available (faster especially on Windows)
if (which.sync("7z", { nothrow: true }) !== null) {
return extract7Zip(file, dest)
}
// if unzip is available use it (usually available on posix systems)
if (which.sync("unzip", { nothrow: true }) !== null) {
await execa("unzip", ["-q", file, "-d", dest], { stdio: "inherit" })
await grantUserWriteAccess(dest)
return dest
}
// fallback to 7z (will install 7z if needed)
return extract7Zip(file, dest)
}