Skip to content

Commit

Permalink
get: use unzipper to decompress .zip files
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra authored and Lulalaby committed Dec 25, 2023
1 parent e7042d5 commit 52469f9
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 21 deletions.
148 changes: 138 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"plist": "^3.1.0",
"rcedit": "^4.0.1",
"tar": "^6.2.0",
"unzipper": "^0.10.14",
"yargs": "^17.7.2"
},
"packageManager": "[email protected]",
Expand Down
20 changes: 9 additions & 11 deletions src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import https from "node:https";
import path from "node:path";

import progress from "cli-progress";
import compressing from "compressing";
import tar from "tar";
import unzipper from "unzipper";

import util from "./util.js";

Expand Down Expand Up @@ -122,10 +122,8 @@ const getNwjs = async (options) => {
C: options.cacheDir
});
} else {
await compressing.zip.uncompress(
out,
options.cacheDir,
);
fs.createReadStream(out)
.pipe(unzipper.Extract({ path: options.cacheDir }));
}
return;
}
Expand Down Expand Up @@ -195,10 +193,8 @@ const getNwjs = async (options) => {
C: options.cacheDir
});
} else {
await compressing.zip.uncompress(
out,
options.cacheDir,
);
fs.createReadStream(out)
.pipe(unzipper.Extract({ path: options.cacheDir }));
}
}

Expand All @@ -225,7 +221,8 @@ const getFfmpeg = async (options) => {

// Check if cache exists.
if (fs.existsSync(out) === true) {
await compressing.zip.uncompress(out, nwDir);
fs.createReadStream(out)
.pipe(unzipper.Extract({ path: nwDir }));
return;
}

Expand Down Expand Up @@ -264,7 +261,8 @@ const getFfmpeg = async (options) => {

// Remove compressed file after download and decompress.
await request;
await compressing.zip.uncompress(out, nwDir);
fs.createReadStream(out)
.pipe(unzipper.Extract({ path: nwDir }));
await util.replaceFfmpeg(options.platform, nwDir);
}

Expand Down

0 comments on commit 52469f9

Please sign in to comment.