Skip to content

Commit

Permalink
Use markedAsFailure for exitCode and only set if undefined.
Browse files Browse the repository at this point in the history
Respect markedAsFailure from your run and exit with an error. This
also only sets the error code if it's not set. That means you can
set the exitCode in your script and it will be respected.
  • Loading branch information
soulgalore committed Jan 5, 2024
1 parent 1ba2be4 commit 674ad76
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bin/browsertime.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ async function run(urls, options) {
const resultDirectory = relative(process.cwd(), storageManager.directory);

// check for errors
for (let eachResult of result) {
for (let errors of eachResult.errors) {
if (errors.length > 0) {
// If we have set the exit code in scripts, respect that
if (process.exitCode === undefined) {
for (let eachResult of result) {
if (eachResult.markedAsFailure === 1) {
process.exitCode = 1;
}
for (let errors of eachResult.errors) {
if (errors.length > 0) {
process.exitCode = 1;
}
}
}
}
log.info(`Wrote data to ${resultDirectory}`);
Expand Down

0 comments on commit 674ad76

Please sign in to comment.