Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 3ae9c8d

Browse files
authored
Merge pull request #47 from bobisjan/exit-with-error
Set exit code to non-zero value on error, fix #42
2 parents 8b768a3 + 5ee98b8 commit 3ae9c8d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

bin/codacy-coverage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
}, function (err) {
4848
loggerImpl.error('Error sending coverage');
4949
loggerImpl.error(err);
50+
process.exitCode = 1;
5051
});
5152
});
5253

test/cli.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,26 @@
4545

4646
helper.setupMockEndpoint('1234', '4321', Joi.compile(bodyObject)).then(function () {
4747
exec('cat ./test/mock/lcov.info | node ./bin/codacy-coverage.js --token 1234 --commit 4321', function (err, res) {
48-
if (err) {
49-
return done(err);
48+
if (!err) {
49+
return done(new Error('Should return with error'));
5050
}
5151

5252
expect(res).to.match(/Status Code \[404\] - Error \[{"error":"not found"}\]/);
53+
expect(err.code).to.equal(1);
5354
//nock.done(); //TODO: Need to figure out how to use nock here. Since it's a separate process, it's not tied together.
5455
done();
5556
});
5657
});
5758
});
5859
it('should be able to set options', function (done) {
5960
exec('cat ./test/mock/no-lines.info | node ./bin/codacy-coverage.js --debug --verbose --token 1234 --commit 4321 --prefix asdf/ --endpoint something --format lcov', function (err, res) {
60-
if (err) {
61-
return done(err);
61+
if (!err) {
62+
return done(new Error('Should return with error'));
6263
}
6364

6465
expect(res).to.match(/Started with: token \["1234"], commitId \["4321"], language \[undefined], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
6566
expect(res).to.match(/Handling input for: token \["1234"], commitId \["4321"], language \[undefined], endpoint \["something"], format \["lcov"], path prefix \["asdf\/"], verbose \[true], debug \[true]/);
67+
expect(err.code).to.equal(1);
6668
done();
6769
});
6870
});

0 commit comments

Comments
 (0)