Permalink
Browse files

improve reading of arguments

  • Loading branch information...
1 parent 7259912 commit 17c00297f742668b1a498322e9e0b55e4a0a54e9 @Floby committed Jul 12, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/arguments.js
View
@@ -40,8 +40,7 @@ exports.parseArgs = function parseArgs() {
function readFiles (arg) {
if(!arg) return;
- var int = parseInt(arg);
- if(isNaN(int)) {
+ if(! /^\d+$/.test(arg)) {
queue.unshift(readFiles);
queue.unshift(readFileName);
}
@@ -84,6 +83,7 @@ exports.parseArgs = function parseArgs() {
}
function readPort(arg) {
+ if(! /^\d+$/.test(arg)) return arg;
var port = parseInt(arg);
if(!isNaN(port)) {
res.port = parseInt(arg);
@@ -113,7 +113,7 @@ exports.parseArgs = function parseArgs() {
while(args.length) {
var f = queue.shift();
var arg = args.shift();
- //console.log('parsing %s using %s', arg, f.name);
+ //console.log('parsing %s using %s', arg, f.name);
var r = f(arg);
if(r) args.unshift(arg);
}

0 comments on commit 17c0029

Please sign in to comment.