Skip to content

Commit

Permalink
fix: replace deprecated zlib with minizlib
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 23, 2024
1 parent 6a56fe4 commit 0129ff5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"fs-extra": "^11.2.0",
"lodash": "^4.17.21",
"memory-stream": "1.0.0",
"minizlib": "^3.0.1",
"npmlog": "^7.0.1",
"queueable": "^5.3.2",
"resolve": "^1.22.8",
Expand All @@ -69,7 +70,6 @@
"tar": "^7.4.3",
"unzipper": "^0.12.3",
"url-join": "^4.0.1",
"which": "^5.0.0",
"zlib": "^1.0.5"
"which": "^5.0.0"
}
}
6 changes: 3 additions & 3 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import crypto from 'crypto';
import { isNumber, isString } from 'lodash';
import { log } from 'npmlog';
import { createWriteStream } from 'fs';
import { createGunzip } from 'zlib';
import { extract as extractTar } from 'tar';
import { Extract as extractZip } from 'unzipper';
import { Gunzip } from "minizlib"

import MemoryStream from 'memory-stream';

Expand All @@ -18,7 +18,7 @@ export type DownloadOptions = {
hashSum?: string,
}

type AnyStream = ReturnType<typeof createGunzip> | ReturnType<typeof createWriteStream> | ReturnType<typeof extractZip> | MemoryStream
type AnyStream = NodeJS.WritableStream | NodeJS.ReadWriteStream;

export function downloadToStream(url: string, stream: AnyStream, hashType: string | null | undefined): Promise<string | null> {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -72,7 +72,7 @@ export async function downloadFile(url: string, opts: string | DownloadOptions):
export async function downloadTgz(url: string, opts: string | DownloadOptions): Promise<string | null> {
const options = isString(opts) ? { path: opts } : opts;

const gunzip = createGunzip();
const gunzip = new Gunzip({});
const extractor = extractTar(options);
gunzip.pipe(extractor);
const sum = await downloadToStream(url, gunzip, options.hashType);
Expand Down

0 comments on commit 0129ff5

Please sign in to comment.