diff --git a/lib/cli/cli.js b/lib/cli/cli.js index 2e004ba4a3..ffbe5dada5 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -52,7 +52,7 @@ exports.main = (argv = process.argv.slice(2)) => { debug('caught error sometime before command handler: %O', err); yargs.showHelp(); console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`); - yargs.exit(1); + process.exitCode = 1; }) .help('help', 'Show usage information & exit') .alias('help', 'h') diff --git a/test/integration/init.spec.js b/test/integration/init.spec.js index 176b852c56..3961b27844 100644 --- a/test/integration/init.spec.js +++ b/test/integration/init.spec.js @@ -23,19 +23,39 @@ describe('init command', function() { } catch (ignored) {} }); - it('should break if no path supplied', function(done) { - invokeMocha( - ['init'], - function(err, result) { - if (err) { - return done(err); - } - expect(result, 'to have failed'); - expect(result.output, 'to match', /not enough non-option arguments/i); - done(); - }, - {stdio: 'pipe'} - ); + describe('when no path is supplied', function() { + it('should fail', function(done) { + invokeMocha( + ['init'], + function(err, result) { + if (err) { + return done(err); + } + expect( + result, + 'to have failed with output', + /not enough non-option arguments/i + ); + done(); + }, + {stdio: 'pipe'} + ); + }); + it('should not throw', function(done) { + invokeMocha( + ['init'], + function(err, result) { + if (err) { + return done(err); + } + expect(result, 'to have failed').and('not to satisfy', { + output: /throw/i + }); + done(); + }, + {stdio: 'pipe'} + ); + }); }); it('should create some files in the dest dir', function(done) {