From 0129ff5b636f7b28092cac41e3f9a03d44b0f6d8 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 23 Oct 2024 02:55:12 -0700 Subject: [PATCH] fix: replace deprecated zlib with minizlib --- package.json | 4 ++-- src/download.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d61b089..f8c27ee 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } } diff --git a/src/download.ts b/src/download.ts index 6a8a9d3..601371e 100644 --- a/src/download.ts +++ b/src/download.ts @@ -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'; @@ -18,7 +18,7 @@ export type DownloadOptions = { hashSum?: string, } -type AnyStream = ReturnType | ReturnType | ReturnType | MemoryStream +type AnyStream = NodeJS.WritableStream | NodeJS.ReadWriteStream; export function downloadToStream(url: string, stream: AnyStream, hashType: string | null | undefined): Promise { return new Promise((resolve, reject) => { @@ -72,7 +72,7 @@ export async function downloadFile(url: string, opts: string | DownloadOptions): export async function downloadTgz(url: string, opts: string | DownloadOptions): Promise { 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);