Skip to content

Commit 312d006

Browse files
Merge branch 'master' of github.com:browserstack/browserstack-cypress-cli into improved_cli
2 parents d0d55d6 + 4a7acc7 commit 312d006

File tree

8 files changed

+24
-3
lines changed

8 files changed

+24
-3
lines changed

bin/commands/generateDownloads.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ module.exports = async function generateDownloads(args) {
3434
logger.error(err);
3535
utils.setUsageReportingFlag(null, args.disableUsageReporting);
3636
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
37+
process.exitCode = Constants.ERROR_EXIT_CODE;
3738
});
3839
};

bin/commands/generateReport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ module.exports = function generateReport(args) {
3535
logger.error(err);
3636
utils.setUsageReportingFlag(null, args.disableUsageReporting);
3737
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
38+
process.exitCode = Constants.ERROR_EXIT_CODE;
3839
});
3940
};

bin/commands/info.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,6 @@ module.exports = function info(args) {
9696
logger.error(err);
9797
utils.setUsageReportingFlag(null, args.disableUsageReporting);
9898
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
99+
process.exitCode = Constants.ERROR_EXIT_CODE;
99100
})
100101
}

bin/commands/runs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ module.exports = function run(args) {
195195
await utils.stopLocalBinary(bsConfig, bs_local, args);
196196

197197
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed');
198+
process.exitCode = Constants.ERROR_EXIT_CODE;
198199
});
199200
}).catch(function (err) {
200201
// Zip Upload failed | Local Start failed
@@ -206,6 +207,7 @@ module.exports = function run(args) {
206207
fileHelpers.deleteZip();
207208
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.userMessages.ZIP_UPLOAD_FAILED}`, Constants.messageTypes.ERROR, 'zip_upload_failed');
208209
}
210+
process.exitCode = Constants.ERROR_EXIT_CODE;
209211
});
210212
}).catch(function (err) {
211213
// Zipping failed
@@ -217,12 +219,14 @@ module.exports = function run(args) {
217219
} catch (err) {
218220
utils.sendUsageReport(bsConfig, args, Constants.userMessages.ZIP_DELETE_FAILED, Constants.messageTypes.ERROR, 'zip_deletion_failed');
219221
}
222+
process.exitCode = Constants.ERROR_EXIT_CODE;
220223
});
221224
}).catch(function (err) {
222225
// md5 check failed
223226
logger.error(err);
224227
logger.error(Constants.userMessages.FAILED_MD5_CHECK);
225228
utils.sendUsageReport(bsConfig, args, Constants.userMessages.MD5_CHECK_FAILED, Constants.messageTypes.ERROR, 'zip_already_uploaded_failed');
229+
process.exitCode = Constants.ERROR_EXIT_CODE;
226230
});
227231
}).catch(function (err) {
228232
// browerstack.json is not valid
@@ -236,11 +240,13 @@ module.exports = function run(args) {
236240

237241
let error_code = utils.getErrorCodeFromMsg(err);
238242
utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code);
243+
process.exitCode = Constants.ERROR_EXIT_CODE;
239244
});
240245
}).catch(function (err) {
241246
logger.error(err);
242247
utils.setUsageReportingFlag(null, args.disableUsageReporting);
243248
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
249+
process.exitCode = Constants.ERROR_EXIT_CODE;
244250
}).finally(function(){
245251
updateNotifier({
246252
pkg,

bin/commands/stop.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ module.exports = function stop(args) {
3131
logger.error(err);
3232
utils.setUsageReportingFlag(null, args.disableUsageReporting);
3333
utils.sendUsageReport(null, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err));
34+
process.exitCode = Constants.ERROR_EXIT_CODE;
3435
})
3536
}

bin/helpers/buildArtifacts.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
193193
messageType = Constants.messageTypes.ERROR;
194194
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
195195
logger.error(message);
196+
process.exitCode = Constants.ERROR_EXIT_CODE;
196197
} else {
197198
messageType = Constants.messageTypes.SUCCESS;
198199
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_SUCCESS.replace('<build-id>', buildId).replace('<user-path>', process.cwd());
@@ -214,5 +215,6 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
214215
}
215216

216217
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode);
218+
process.exitCode = Constants.ERROR_EXIT_CODE;
217219
}
218220
};

bin/helpers/constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ const usageReportingConstants = {
192192

193193
const LATEST_VERSION_SYNTAX_REGEX = /\d*.latest(.\d*)?/gm
194194

195+
const ERROR_EXIT_CODE = 1;
196+
195197
module.exports = Object.freeze({
196198
syncCLI,
197199
userMessages,
@@ -207,5 +209,6 @@ module.exports = Object.freeze({
207209
SPEC_TOTAL_CHAR_LIMIT,
208210
METADATA_CHAR_BUFFER_PER_SPEC,
209211
usageReportingConstants,
210-
LATEST_VERSION_SYNTAX_REGEX
212+
LATEST_VERSION_SYNTAX_REGEX,
213+
ERROR_EXIT_CODE
211214
});

bin/helpers/reporterHTML.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ function generateCypressCombinationSpecReportDataWithConfigJson(combination){
277277
});
278278
combination.tests = sessionTests;
279279
resolve(combination.tests);
280-
} catch (error) { reject(error) }
280+
} catch (error) {
281+
process.exitCode = Constants.ERROR_EXIT_CODE;
282+
reject(error);
283+
}
281284
})
282285
}
283286

@@ -308,7 +311,10 @@ function generateCypressCombinationSpecReportDataWithoutConfigJson(combination){
308311
});
309312
combination.tests = sessionTests;
310313
resolve(combination.tests);
311-
} catch (error) { reject(error) }
314+
} catch (error) {
315+
process.exitCode = Constants.ERROR_EXIT_CODE;
316+
reject(error);
317+
}
312318
})
313319
}
314320

0 commit comments

Comments
 (0)