Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DownloadPackageV1] replace decompress-zip with extract-zip #19570

79 changes: 79 additions & 0 deletions Tasks/DownloadPackageV1/_buildConfigs/Node20/package-lock.json

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

3 changes: 2 additions & 1 deletion Tasks/DownloadPackageV1/_buildConfigs/Node20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"azure-pipelines-tasks-packaging-common": "3.206.0",
"azure-pipelines-tasks-utility-common": "^3.198.1",
"decompress-zip": "0.3.3",
"tar-fs": "1.16.3"
"tar-fs": "1.16.3",
"extract-zip": "2.0.1"
},
"devDependencies": {
"typescript": "5.1.6"
Expand Down
18 changes: 16 additions & 2 deletions Tasks/DownloadPackageV1/packagefile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import * as tl from "azure-pipelines-task-lib/task";
import * as path from "path";
import * as fs from "fs";
#if NODE20
import * as extract from 'extract-zip'
#else
var DecompressZip = require('decompress-zip');
#endif

var tar = require("tar-fs");
var zlib = require("zlib");
var DecompressZip = require('decompress-zip');


export class PackageFile {
public readonly win: boolean;
Expand Down Expand Up @@ -62,7 +68,14 @@ export class PackageFile {
private async unzip(zipLocation: string, unzipLocation: string): Promise<void> {
return new Promise<void>(function(resolve, reject) {
tl.debug("Extracting " + zipLocation + " to " + unzipLocation);

#if NODE20
tl.debug(`Using extract-zip package for extracting archive`);
extract(this.zipLocation, { dir: unzipLocation }).then(() => {
resolve();
}).catch((error) => {
reject(error);
});
#else
var unzipper = new DecompressZip(zipLocation);
unzipper.on("error", err => {
return reject(tl.loc("ExtractionFailed", err));
Expand All @@ -75,6 +88,7 @@ export class PackageFile {
unzipper.extract({
path: path.normalize(unzipLocation)
});
#endif
});
}
}
5 changes: 3 additions & 2 deletions _generated/DownloadPackageV1/packagefile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as tl from "azure-pipelines-task-lib/task";
import * as path from "path";
import * as fs from "fs";
var DecompressZip = require('decompress-zip');

var tar = require("tar-fs");
var zlib = require("zlib");
var DecompressZip = require('decompress-zip');


export class PackageFile {
public readonly win: boolean;
Expand Down Expand Up @@ -62,7 +64,6 @@ export class PackageFile {
private async unzip(zipLocation: string, unzipLocation: string): Promise<void> {
return new Promise<void>(function(resolve, reject) {
tl.debug("Extracting " + zipLocation + " to " + unzipLocation);

var unzipper = new DecompressZip(zipLocation);
unzipper.on("error", err => {
return reject(tl.loc("ExtractionFailed", err));
Expand Down
79 changes: 79 additions & 0 deletions _generated/DownloadPackageV1_Node20/package-lock.json

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

3 changes: 2 additions & 1 deletion _generated/DownloadPackageV1_Node20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"azure-pipelines-tasks-packaging-common": "3.206.0",
"azure-pipelines-tasks-utility-common": "^3.198.1",
"decompress-zip": "0.3.3",
"tar-fs": "1.16.3"
"tar-fs": "1.16.3",
"extract-zip": "2.0.1"
},
"devDependencies": {
"typescript": "5.1.6"
Expand Down
21 changes: 8 additions & 13 deletions _generated/DownloadPackageV1_Node20/packagefile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as tl from "azure-pipelines-task-lib/task";
import * as path from "path";
import * as fs from "fs";
import * as extract from 'extract-zip'

var tar = require("tar-fs");
var zlib = require("zlib");
var DecompressZip = require('decompress-zip');


export class PackageFile {
public readonly win: boolean;
Expand Down Expand Up @@ -62,18 +64,11 @@ export class PackageFile {
private async unzip(zipLocation: string, unzipLocation: string): Promise<void> {
return new Promise<void>(function(resolve, reject) {
tl.debug("Extracting " + zipLocation + " to " + unzipLocation);

var unzipper = new DecompressZip(zipLocation);
unzipper.on("error", err => {
return reject(tl.loc("ExtractionFailed", err));
});
unzipper.on("extract", () => {
tl.debug("Extracted " + zipLocation + " to " + unzipLocation + " successfully");
return resolve();
});

unzipper.extract({
path: path.normalize(unzipLocation)
tl.debug(`Using extract-zip package for extracting archive`);
extract(this.zipLocation, { dir: unzipLocation }).then(() => {
resolve();
}).catch((error) => {
reject(error);
});
});
}
Expand Down
Loading