Skip to content

Commit eb5efab

Browse files
committed
Fix server never getting started when using --no-build flag
1 parent cdab2ce commit eb5efab

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

lib/commands/fastboot.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const ServerTask = require('../tasks/fastboot-server');
66
const SilentError = require('silent-error');
77

88
const blockForever = () => (new RSVP.Promise(() => {}));
9-
const noop = function() { };
109

1110
module.exports = function(addon) {
1211
return {
@@ -31,11 +30,12 @@ module.exports = function(addon) {
3130
run(options) {
3231
const runBuild = () => this.runBuild(options);
3332
const runServer = () => this.runServer(options);
33+
const startServer = (serverTask) => this.startServer(serverTask, options);
3434
const blockForever = this.blockForever;
3535

3636
return this.checkPort(options)
3737
.then(runServer) // starts on postBuild SIGHUP
38-
.then(options.build ? runBuild : noop)
38+
.then(options.build ? runBuild : startServer)
3939
.then(blockForever);
4040
},
4141

@@ -45,7 +45,12 @@ module.exports = function(addon) {
4545
ui: this.ui,
4646
addon: addon
4747
});
48-
return serverTask.run(options);
48+
serverTask.run(options);
49+
return serverTask;
50+
},
51+
52+
startServer(serverTask, options) {
53+
serverTask.start(options);
4954
},
5055

5156
runBuild(options) {

test/lib-commands-fastboot-test.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ describe('fastboot command', function() {
2525
blockForever: RSVP.resolve,
2626
checkPort: RSVP.resolve,
2727
runServer: RSVP.resolve,
28+
startServer: RSVP.resolve,
2829
tasks: {
2930
Build: CoreObject.extend({ run() { buildRunCalled = true; } }),
3031
BuildWatch: CoreObject.extend({ run() { buildWatchRunCalled = true; } }),
31-
},
32+
}
3233
});
3334
});
3435

@@ -57,6 +58,30 @@ describe('fastboot command', function() {
5758
});
5859
});
5960

61+
describe('run server', function() {
62+
let command, serverStartCalled;
63+
64+
beforeEach(function() {
65+
serverStartCalled = false;
66+
command = new FastbootCommand({
67+
blockForever: RSVP.resolve,
68+
checkPort: RSVP.resolve,
69+
runBuild: RSVP.resolve,
70+
ServerTask: CoreObject.extend({
71+
run() { },
72+
start() { serverStartCalled = true; }
73+
})
74+
});
75+
});
76+
77+
it('immediately starts server when build=false', function() {
78+
const options = new CommandOptions({ build: false });
79+
return command.run(options).then(() => {
80+
expect(serverStartCalled).to.equal(true);
81+
});
82+
});
83+
});
84+
6085
describe('port check', function() {
6186
let command, isCalled;
6287

0 commit comments

Comments
 (0)