Skip to content

Commit f8aa0bf

Browse files
Merge pull request #1184 from browserstack/APS-22106-replace-decompress-with-adm-zip
[APS-22106] replace decompress@4.2.1 with adm-zip@0.6.1
2 parents 8b0e9b3 + adc6c2b commit f8aa0bf

6 files changed

Lines changed: 31 additions & 421 deletions

File tree

‎bin/helpers/buildArtifacts.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const logger = require('./logger').winstonLogger,
1111
const { default: axios } = require('axios');
1212
const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
1313
const FormData = require('form-data');
14-
const decompress = require('decompress');
14+
const AdmZip = require('adm-zip');
1515
const unzipper = require("unzipper");
1616
const { setAxiosProxy } = require('./helper');
1717

@@ -154,10 +154,11 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
154154
const unzipFile = async (filePath, fileName) => {
155155
return new Promise( async (resolve, reject) => {
156156
try {
157-
await decompress(path.join(filePath, fileName), filePath);
157+
const zip = new AdmZip(path.join(filePath, fileName));
158+
await zip.extractAllToAsync(filePath, /* overwrite */ true);
158159
resolve();
159160
} catch (error) {
160-
logger.debug(`Error unzipping with decompress, trying with unzipper. Stacktrace: ${error}.`);
161+
logger.debug(`Error unzipping with adm-zip, trying with unzipper. Stacktrace: ${error}.`);
161162
try {
162163
fs.createReadStream(path.join(filePath, fileName))
163164
.pipe(unzipper.Extract({ path: filePath }))

‎bin/helpers/reporterHTML.js‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require('fs'),
66
utils = require("./utils"),
77
Constants = require('./constants'),
88
config = require("./config"),
9-
decompress = require('decompress');
9+
AdmZip = require('adm-zip');
1010
const { isTurboScaleSession } = require('../helpers/atsHelper');
1111

1212
const { setAxiosProxy } = require('./helper');
@@ -171,15 +171,14 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
171171

172172
const unzipFile = async (filePath, fileName) => {
173173
return new Promise( async (resolve, reject) => {
174-
await decompress(path.join(filePath, fileName), filePath)
175-
.then((files) => {
176-
let message = "Unzipped the json and html successfully."
177-
resolve(message);
178-
})
179-
.catch((error) => {
174+
try {
175+
const zip = new AdmZip(path.join(filePath, fileName));
176+
await zip.extractAllToAsync(filePath, /* overwrite */ true);
177+
resolve("Unzipped the json and html successfully.");
178+
} catch (error) {
180179
reject(error);
181180
process.exitCode = Constants.ERROR_EXIT_CODE;
182-
});
181+
}
183182
});
184183
}
185184

0 commit comments

Comments
 (0)