Skip to content

Commit

Permalink
Merge pull request #346 from simonihmig/fix-fastboot-no-build
Browse files Browse the repository at this point in the history
Fix server never getting started when using --no-build flag
  • Loading branch information
rwjblue committed Feb 3, 2017
2 parents cdab2ce + eb5efab commit e65bd3e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/commands/fastboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const ServerTask = require('../tasks/fastboot-server');
const SilentError = require('silent-error');

const blockForever = () => (new RSVP.Promise(() => {}));
const noop = function() { };

module.exports = function(addon) {
return {
Expand All @@ -31,11 +30,12 @@ module.exports = function(addon) {
run(options) {
const runBuild = () => this.runBuild(options);
const runServer = () => this.runServer(options);
const startServer = (serverTask) => this.startServer(serverTask, options);
const blockForever = this.blockForever;

return this.checkPort(options)
.then(runServer) // starts on postBuild SIGHUP
.then(options.build ? runBuild : noop)
.then(options.build ? runBuild : startServer)
.then(blockForever);
},

Expand All @@ -45,7 +45,12 @@ module.exports = function(addon) {
ui: this.ui,
addon: addon
});
return serverTask.run(options);
serverTask.run(options);
return serverTask;
},

startServer(serverTask, options) {
serverTask.start(options);
},

runBuild(options) {
Expand Down
27 changes: 26 additions & 1 deletion test/lib-commands-fastboot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ describe('fastboot command', function() {
blockForever: RSVP.resolve,
checkPort: RSVP.resolve,
runServer: RSVP.resolve,
startServer: RSVP.resolve,
tasks: {
Build: CoreObject.extend({ run() { buildRunCalled = true; } }),
BuildWatch: CoreObject.extend({ run() { buildWatchRunCalled = true; } }),
},
}
});
});

Expand Down Expand Up @@ -57,6 +58,30 @@ describe('fastboot command', function() {
});
});

describe('run server', function() {
let command, serverStartCalled;

beforeEach(function() {
serverStartCalled = false;
command = new FastbootCommand({
blockForever: RSVP.resolve,
checkPort: RSVP.resolve,
runBuild: RSVP.resolve,
ServerTask: CoreObject.extend({
run() { },
start() { serverStartCalled = true; }
})
});
});

it('immediately starts server when build=false', function() {
const options = new CommandOptions({ build: false });
return command.run(options).then(() => {
expect(serverStartCalled).to.equal(true);
});
});
});

describe('port check', function() {
let command, isCalled;

Expand Down

0 comments on commit e65bd3e

Please sign in to comment.