browserstack-cypress-cli 1.31.4 → 1.31.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ const logger = require('./logger').winstonLogger,
10
10
 
11
11
  const request = require('request');
12
12
  const decompress = require('decompress');
13
-
13
+ const unzipper = require("unzipper");
14
14
 
15
15
  let BUILD_ARTIFACTS_TOTAL_COUNT = 0;
16
16
  let BUILD_ARTIFACTS_FAIL_COUNT = 0;
@@ -121,13 +121,15 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
121
121
  reject(err);
122
122
  });
123
123
  writer.on('close', async () => {
124
- if (!error) {
125
- await unzipFile(filePath, fileName);
126
- fs.unlinkSync(tmpFilePath);
127
- resolve(true);
124
+ try {
125
+ if (!error) {
126
+ await unzipFile(filePath, fileName);
127
+ fs.unlinkSync(tmpFilePath);
128
+ }
129
+ } catch (error) {
130
+ reject(error);
128
131
  }
129
- //no need to call the reject here, as it will have been called in the
130
- //'error' stream;
132
+ resolve(true);
131
133
  });
132
134
  }
133
135
  });
@@ -136,13 +138,25 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
136
138
 
137
139
  const unzipFile = async (filePath, fileName) => {
138
140
  return new Promise( async (resolve, reject) => {
139
- await decompress(path.join(filePath, fileName), filePath)
140
- .then((files) => {
141
+ try {
142
+ await decompress(path.join(filePath, fileName), filePath);
141
143
  resolve();
142
- })
143
- .catch((error) => {
144
- reject(error);
145
- });
144
+ } catch (error) {
145
+ logger.debug(`Error unzipping with decompress, trying with unzipper. Stacktrace: ${error}.`);
146
+ try {
147
+ fs.createReadStream(path.join(filePath, fileName))
148
+ .pipe(unzipper.Extract({ path: filePath }))
149
+ .on("close", () => {
150
+ resolve();
151
+ })
152
+ .on("error", (err) => {
153
+ reject(err);
154
+ });
155
+ } catch (unzipperError) {
156
+ logger.debug(`Unzipper package error: ${unzipperError}`);
157
+ reject(Constants.userMessages.BUILD_ARTIFACTS_UNZIP_FAILURE);
158
+ }
159
+ }
146
160
  });
147
161
  }
148
162
 
@@ -123,7 +123,8 @@ const userMessages = {
123
123
  CYPRESS_PORT_WARNING:
124
124
  "The requested port number <x> is ignored. The default BrowserStack port will be used for this execution",
125
125
  CYPRESS_INTERACTIVE_SESSION_CONFLICT_VALUES:
126
- "Conflicting values (True & False) were found for the interactive_debugging capability. Please resolve this issue to proceed further."
126
+ "Conflicting values (True & False) were found for the interactive_debugging capability. Please resolve this issue to proceed further.",
127
+ BUILD_ARTIFACTS_UNZIP_FAILURE: "Failed to unzip build artifacts.",
127
128
  };
128
129
 
129
130
  const validationMessages = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.31.4",
3
+ "version": "1.31.5",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,8 @@
34
34
  "windows-release": "^5.1.0",
35
35
  "winston": "2.4.4",
36
36
  "yargs": "14.2.3",
37
- "decompress": "4.2.1"
37
+ "decompress": "4.2.1",
38
+ "unzipper": "^0.12.3"
38
39
  },
39
40
  "repository": {
40
41
  "type": "git",