Skip to content

Commit

Permalink
[AzureRMDeployCommon] Replace decompress-zip with node-stream-zip (#290)
Browse files Browse the repository at this point in the history
* [AzureRMDeployCommon] Replace decompress-zip with node-stream-zip

* Update ziputility.ts
  • Loading branch information
kirill-ivlev authored Mar 1, 2024
1 parent 152876b commit 06fb19d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 128 deletions.
102 changes: 1 addition & 101 deletions common-npm-packages/azurermdeploycommon/package-lock.json

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

3 changes: 1 addition & 2 deletions common-npm-packages/azurermdeploycommon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-pipelines-tasks-azurermdeploycommon",
"version": "3.235.0",
"version": "3.236.0",
"description": "Common Lib for Azure ARM REST apis",
"repository": {
"type": "git",
Expand All @@ -21,7 +21,6 @@
"@types/q": "1.0.7",
"archiver": "2.1.1",
"azure-pipelines-task-lib": "^3.1.0",
"decompress-zip": "^0.3.3",
"jsonwebtoken": "^8.5.1",
"ltx": "2.6.2",
"node-stream-zip": "1.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@ import tl = require('azure-pipelines-task-lib/task');
import path = require('path');
import Q = require('q');
import fs = require('fs');
import StreamZip = require('node-stream-zip');
var DecompressZip = require('decompress-zip');
import StreamZip from 'node-stream-zip';
var archiver = require('archiver');

export async function unzip(zipLocation, unzipLocation) {
var defer = Q.defer();
if(tl.exist(unzipLocation)) {
tl.rmRF(unzipLocation);
}
var unzipper = new DecompressZip(zipLocation);
tl.debug('extracting ' + zipLocation + ' to ' + unzipLocation);
unzipper.on('error', function (error) {
defer.reject(error);
});
unzipper.on('extract', function (log) {
tl.debug('extracted ' + zipLocation + ' to ' + unzipLocation + ' Successfully');
defer.resolve(unzipLocation);
});
unzipper.extract({
path: unzipLocation
});
return defer.promise;
tl.mkdirP(unzipLocation);
const zip = new StreamZip.async({ file: zipLocation});
zip.extract(null, unzipLocation).then(() => {
zip.close();
defer.resolve();
}).catch((error) => {
console.log(`error extracting ${zipLocation}: ${error}`);
defer.reject(error);
})
}

export async function archiveFolder(folderPath, targetPath, zipName) {
Expand Down Expand Up @@ -53,17 +48,16 @@ export async function archiveFolder(folderPath, targetPath, zipName) {
*/
export async function getArchivedEntries(archivedPackage: string) {
var deferred = Q.defer();
var unzipper = new DecompressZip(archivedPackage);
unzipper.on('error', function (error) {
const zip = new StreamZip.async({file: archivedPackage});
zip.entries().then(entries => {
var packageConmponent = {
'entries': Object.keys(entries)
}
zip.close();
deferred.resolve(packageConmponent);
}).catch(error => {
deferred.reject(error);
});
unzipper.on('list', function (files) {
var packageComponent = {
"entries":files
};
deferred.resolve(packageComponent);
});
unzipper.list();
})
return deferred.promise;
}

Expand Down

0 comments on commit 06fb19d

Please sign in to comment.