Skip to content

Commit

Permalink
Merge pull request #16 from apinnecke/master
Browse files Browse the repository at this point in the history
fix(cli): Fixed cli exit code for empty array
  • Loading branch information
hutson authored May 27, 2017
2 parents 647a7ad + 16b65ed commit 0330f1b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ conventionalGithubReleaser({
process.exit(1);
}

if (0 === data.length) {
if (flags.verbose) {
console.log('No GitHub releases created because no git tags available to work with.');
}

process.exit(0);
}

var allRejected = true;

for (var i = data.length - 1; i >= 0 ; i--) {
Expand Down
35 changes: 35 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
var expect = require('chai').expect;
var fs = require('fs');
var Q = require('q');
var githubRemoveAllReleases = require('github-remove-all-releases');
var shell = require('shelljs');
var spawn = require('child_process').spawn;
Expand Down Expand Up @@ -64,6 +65,40 @@ describe('cli', function() {
});
});

it('should work with no releases', function(done) {
Q.Promise(function(resolve, reject) {
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token, '-v'], {
stdio: [process.stdin, null, null]
});

cp.on('error', function(code) {
reject('Process exits with code ' + code);
});

cp.on('close', function(code) {
expect(code).to.equal(0);

resolve();
});
}).then(function() {
// we call it a second time, because there no tags are left to create a release from
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token, '-v'], {
stdio: [process.stdin, null, null]
});

cp.on('error', function(code) {
done('Process exits with code ' + code);
});

cp.on('close', function(code) {
// this time we also expect the cli to exit with code 0 due to #17
expect(code).to.equal(0);

done();
});
});
});

it('should print out error message and exit with `1` if all results error', function(done) {
var cp = spawn(cliPath, ['--pkg', __dirname + '/fixtures/_package.json', '-t', AUTH.token], {
stdio: [process.stdin, null, null]
Expand Down

0 comments on commit 0330f1b

Please sign in to comment.