Permalink
Browse files

Merge pull request #1040 from isao/bz6160815

fix bz6160815: port argument must be an integer
  • Loading branch information...
2 parents 0eb815a + c17ecf8 commit 6b8ca8889970c8c2719e90d028e27f6c6cb84d05 @isao isao committed Mar 21, 2013
Showing with 31 additions and 1 deletion.
  1. +3 −1 lib/app/commands/start.js
  2. +28 −0 tests/unit/lib/app/commands/test-start.js
@@ -76,7 +76,9 @@ exports.run = function(params, opts, callback) {
pack = store.config.readConfigJSON(path.join(root, 'package.json'));
- options.port = params[0] || appConfig.appPort || process.env.PORT || 8666;
+ options.port = parseInt(params[0], 10) || appConfig.appPort;
+ options.port = options.port || process.env.PORT || 8666;
+
if (inputOptions.context) {
options.context = inputOptions.context;
}
@@ -84,6 +84,34 @@ YUI().use('mojito', 'mojito-test-extra', 'test', function(Y) {
A.areSame(8667, port);
},
+ 'test run start string port': function() {
+ A.areSame(0, listenCalls);
+ start.run(['8888'], null, function() {});
+ A.areSame(1, listenCalls);
+ A.areSame(8888, port);
+ },
+
+ 'test run start funny string port': function() {
+ A.areSame(0, listenCalls);
+ start.run(['07777a.bc'], null, function() {});
+ A.areSame(1, listenCalls);
+ A.areSame(7777, port);
+ },
+
+ 'test run start port is "foo"': function() {
+ A.areSame(0, listenCalls);
+ start.run(['foo'], null, function() {});
+ A.areSame(1, listenCalls);
+ A.areSame(8666, port);
+ },
+
+ 'test run start with args ["app", "."]': function() {
+ A.areSame(0, listenCalls);
+ start.run(["app", "."], null, function() {});
+ A.areSame(1, listenCalls);
+ A.areSame(8666, port);
+ },
+
'test run start context': function() {
var options = {
context: "environment:production"

0 comments on commit 6b8ca88

Please sign in to comment.