Skip to content

Commit

Permalink
Merge branch 'master' into oli/parent-output-path
Browse files Browse the repository at this point in the history
  • Loading branch information
oligriffiths committed Mar 30, 2018
2 parents 50a1a59 + 9dea8e9 commit b8d799e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 8 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const path = require('path');
const CliError = require('./errors/cli');
const broccoli = require('./index');
const messages = require('./messages');
const CliError = require('./errors/cli');

module.exports = function broccoliCLI(args) {
// always require a fresh commander, as it keeps state at module scope
Expand Down Expand Up @@ -45,7 +46,10 @@ module.exports = function broccoliCLI(args) {
console.error(e.message);
return process.exit(1);
}

throw e;
}

const outputTree = new TreeSync(builder.outputPath, outputDir);

watcher.on('buildSuccess', function() {
Expand All @@ -70,7 +74,7 @@ module.exports = function broccoliCLI(args) {
.action((outputDir, options) => {
if (outputDir && options.outputPath) {
console.error('option --output-path and [target] cannot be passed at same time');
process.exit(1);
return process.exit(1);
}

if (options.outputPath) {
Expand All @@ -88,6 +92,8 @@ module.exports = function broccoliCLI(args) {
console.error(e.message);
return process.exit(1);
}

throw e;
}

const builder = getBuilder(options);
Expand Down Expand Up @@ -130,7 +136,7 @@ module.exports = function broccoliCLI(args) {

if (!actionPromise) {
program.outputHelp();
process.exit(1);
return process.exit(1);
}

return actionPromise || RSVP.resolve();
Expand Down
15 changes: 6 additions & 9 deletions test/cli_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,8 @@ describe('cli', function() {

context('and with [target]', function() {
it('exits with error', function() {
return cli(['node', 'broccoli', 'build', 'dist', '--output-path', 'dist']).then(() => {
chai.expect(exitStub).to.be.calledWith(1);
});
cli(['node', 'broccoli', 'build', 'dist', '--output-path', 'dist']);
chai.expect(exitStub).to.be.calledWith(1);
});

it('outputs error reason to console', function() {
Expand Down Expand Up @@ -375,9 +374,8 @@ describe('cli', function() {
context('and with folder already existing', function() {
it('exits with error', function() {
sinon.stub(broccoli, 'server').value({ serve() {} });
return cli(['node', 'broccoli', 'serve', '--output-path', 'subdir']).then(() => {
chai.expect(exitStub).to.be.calledWith(1);
});
cli(['node', 'broccoli', 'serve', '--output-path', 'subdir']);
chai.expect(exitStub).to.be.calledWith(1);
});

it('outputs error reason to console', function() {
Expand All @@ -390,9 +388,8 @@ describe('cli', function() {
);

sinon.stub(broccoli, 'server').value({ serve() {} });
return cli(['node', 'broccoli', 'serve', '--output-path', 'subdir']).then(() => {
consoleMock.verify();
});
cli(['node', 'broccoli', 'serve', '--output-path', 'subdir']);
consoleMock.verify();
});
});
});
Expand Down

0 comments on commit b8d799e

Please sign in to comment.