Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix exit code when linting from CI #6412

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions tools/jslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,28 @@ if (cluster.isMaster) {
sendWork(worker);
});

process.on('exit', function() {
process.on('exit', function(code) {
if (showProgress) {
curPath = 'Done';
printProgress();
outFn('\r\n');
}
process.exit(failures ? 1 : 0);
if (code === 0)
process.exit(failures ? 1 : 0);
});

for (i = 0; i < numCPUs; ++i)
cluster.fork().on('message', onWorkerMessage);
cluster.fork().on('message', onWorkerMessage).on('exit', onWorkerExit);

function onWorkerMessage(results) {
if (typeof results !== 'number') {
// The worker sent us results that are not all successes
if (!workerConfig.sendAll)
if (workerConfig.sendAll) {
failures += results.errorCount;
results = results.results;
} else {
failures += results.length;
}
outFn(formatter(results) + '\r\n');
printProgress();
} else {
Expand All @@ -151,6 +156,11 @@ if (cluster.isMaster) {
sendWork(this);
}

function onWorkerExit(code, signal) {
if (code !== 0 || signal)
process.exit(2);
}

function sendWork(worker) {
if (!files || !files.length) {
// We either just started or we have no more files to lint for the current
Expand Down Expand Up @@ -245,7 +255,7 @@ if (cluster.isMaster) {
}
}
}
process.send(results);
process.send({ results: results, errorCount: report.errorCount });
} else if (report.errorCount === 0) {
// No errors, return number of successful lint operations
process.send(files.length);
Expand Down