Skip to content

Commit 9f23cb2

Browse files
mscdexFishrock123
authored andcommittedMay 4, 2016
tools: fix exit code when linting from CI
Before this, if there were lint errors reported by `make jslint-ci`, the process would still exit with an exit code of zero. This commit fixes that to align with `make jslint` (exit with non-zero on lint errors). PR-URL: #6412 Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Phillip Johnsen <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent fc0fbf1 commit 9f23cb2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed
 

‎tools/jslint.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,28 @@ if (cluster.isMaster) {
125125
sendWork(worker);
126126
});
127127

128-
process.on('exit', function() {
128+
process.on('exit', function(code) {
129129
if (showProgress) {
130130
curPath = 'Done';
131131
printProgress();
132132
outFn('\r\n');
133133
}
134-
process.exit(failures ? 1 : 0);
134+
if (code === 0)
135+
process.exit(failures ? 1 : 0);
135136
});
136137

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

140141
function onWorkerMessage(results) {
141142
if (typeof results !== 'number') {
142143
// The worker sent us results that are not all successes
143-
if (!workerConfig.sendAll)
144+
if (workerConfig.sendAll) {
145+
failures += results.errorCount;
146+
results = results.results;
147+
} else {
144148
failures += results.length;
149+
}
145150
outFn(formatter(results) + '\r\n');
146151
printProgress();
147152
} else {
@@ -151,6 +156,11 @@ if (cluster.isMaster) {
151156
sendWork(this);
152157
}
153158

159+
function onWorkerExit(code, signal) {
160+
if (code !== 0 || signal)
161+
process.exit(2);
162+
}
163+
154164
function sendWork(worker) {
155165
if (!files || !files.length) {
156166
// We either just started or we have no more files to lint for the current
@@ -245,7 +255,7 @@ if (cluster.isMaster) {
245255
}
246256
}
247257
}
248-
process.send(results);
258+
process.send({ results: results, errorCount: report.errorCount });
249259
} else if (report.errorCount === 0) {
250260
// No errors, return number of successful lint operations
251261
process.send(files.length);

0 commit comments

Comments
 (0)
Please sign in to comment.