Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #5352] fix issue were we accidentally were checking unexpected… #5354

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ var PortFinder = require('portfinder');
var win = require('../utilities/windows-admin');
var EOL = require('os').EOL;

PortFinder.basePort = 49152;

var getPort = Promise.denodeify(PortFinder.getPort);
var defaultPort = process.env.PORT || 4200;

Expand All @@ -26,7 +24,7 @@ module.exports = Command.extend({
{ name: 'insecure-proxy', type: Boolean, default: false, aliases: ['inspr'], description: 'Set false to proxy self-signed SSL certificates' },
{ name: 'watcher', type: String, default: 'events', aliases: ['w'] },
{ name: 'live-reload', type: Boolean, default: true, aliases: ['lr'] },
{ name: 'live-reload-host', type: String, aliases: ['lrh'], description: 'Defaults to host' },
{ name: 'live-reload-host', type: String, default: 'localhost', aliases: ['lrh'], description: 'Defaults to host' },
{ name: 'live-reload-base-url', type: String, description: 'Defaults to baseURL', aliases: ['lrbu'] },
{ name: 'live-reload-port', type: Number, aliases: ['lrp'], description: '(Defaults to port number within [49152...65535])' },
{ name: 'environment', type: String, default: 'development', aliases: ['e', { 'dev': 'development' }, { 'prod': 'production' }] },
Expand All @@ -39,7 +37,10 @@ module.exports = Command.extend({
run: function(commandOptions) {
var port = commandOptions.port ? Promise.resolve(commandOptions.port) : getPort({ host: commandOptions.host });
var liveReloadHost = commandOptions.liveReloadHost || commandOptions.host;
var liveReloadPort = commandOptions.liveReloadPort ? Promise.resolve(commandOptions.liveReloadPort) : getPort({ host: liveReloadHost });
var liveReloadPort = commandOptions.liveReloadPort ? Promise.resolve(commandOptions.liveReloadPort) : getPort({
host: '127.0.0.1',
port: 49152
});

return Promise.all([liveReloadPort, port]).then(function(values) {
var liveReloadPort = values[0];
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/commands/serve-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ describe('serve command', function() {
});
});

it('has correct liveLoadHost (default)', function() {
var getPortOpts;
getPortStub = function(options, callback) {
getPortOpts = options;
callback(null, 49152);
};

return command.validateAndRun([
]).then(function() {
var serveRun = tasks.Serve.prototype.run;
var runOps = serveRun.calledWith[0][0];

expect(serveRun.called).to.equal(1, 'expected run to be called once');

expect(getPortOpts.host).to.equal('localhost', 'gets a port based on the liveReload host');
expect(runOps.liveReloadHost).to.equal('localhost', 'has correct liveReload host');
});
});

it('has correct liveLoadHost', function() {
var getPortOpts;
getPortStub = function(options, callback) {
Expand Down