This commit is contained in:
Generated
+86
-1325
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -54,7 +54,7 @@
|
||||
"tar": "^7.5.22",
|
||||
"through2": "^5.0.12",
|
||||
"tmp-file": "^2.0.1",
|
||||
"unzip-stream": "^0.3.4",
|
||||
"unzipper": "^0.12.5",
|
||||
"vinyl": "^3.0.1",
|
||||
"vinyl-fs": "^4.0.2"
|
||||
},
|
||||
@@ -73,7 +73,7 @@
|
||||
"@types/tail": "^2.2.3",
|
||||
"@types/tar": "^7.0.87",
|
||||
"@types/through2": "^5.0.0",
|
||||
"@types/unzip-stream": "^0.3.4",
|
||||
"@types/unzipper": "^0.10.11",
|
||||
"eslint": "^10.13.0",
|
||||
"prettier": "^3.9.10",
|
||||
"tsdown": "0.22.14",
|
||||
|
||||
@@ -4,9 +4,9 @@ import fse from "fs-extra";
|
||||
import got, { type Progress, type Request } from "got";
|
||||
import path from "path";
|
||||
import ps from "promise-streams";
|
||||
import type { Stream, Writable } from "stream";
|
||||
import { type Stream, type Writable } from "stream";
|
||||
import { x as tarX } from "tar";
|
||||
import unzip from "unzip-stream";
|
||||
import unzipper from "unzipper";
|
||||
|
||||
export interface DownloadOptions {
|
||||
progress?: boolean;
|
||||
@@ -19,7 +19,7 @@ const DEFAULT_OPTIONS: DownloadOptions = { progress: true, strip: 1, executable:
|
||||
type Extractor = (stream: Request, dest: string, options: DownloadOptions) => Stream;
|
||||
|
||||
const ZIP_EXTRACTOR: Extractor = (stream: Request, dest: string, options: DownloadOptions): Stream => {
|
||||
return stream.pipe(unzip.Parse()).on("entry", (entry: any) => {
|
||||
return stream.pipe(unzipper.Parse()).on("entry", (entry: unzipper.Entry) => {
|
||||
const filePath = entry.path.split("/").slice(options.strip).join(path.sep);
|
||||
if (filePath.length > 0) {
|
||||
if (entry.type === "Directory") {
|
||||
@@ -94,7 +94,7 @@ const progressBar = new ProgressBar();
|
||||
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
|
||||
options = { ...DEFAULT_OPTIONS, ...options };
|
||||
fse.ensureDirSync(dest);
|
||||
let stream: Request = got.stream(url);
|
||||
let stream: Request = got.stream(url, { decompress: false });
|
||||
if (options.progress) {
|
||||
stream = progressBar.handle(stream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user