Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

opt keys are case insensitive but opt values and args are case sensit…

…ive.
  • Loading branch information...
commit ddb32ee011394beb7d43a62497c3d1811719123f 1 parent 46e9379
@thatismatt authored
Showing with 16 additions and 2 deletions.
  1. +2 −2 lib/josi/utilities.js
  2. +14 −0 tests/utilities.js
View
4 lib/josi/utilities.js
@@ -37,9 +37,9 @@ this.processARGV = function(argv) {
.forEach(function(arg) {
var match = optsRE.exec(arg);
if (match) {
- opts[match[1].toLowerCase()] = match[2].toLowerCase();
+ opts[match[1].toLowerCase()] = match[2];
} else {
- args.push(arg.toLowerCase());
+ args.push(arg);
}
});
return {
View
14 tests/utilities.js
@@ -40,6 +40,20 @@ this.tests = {
var processed = utilities.processARGV(['', '', 'atask', 'arg']);
assert.equal(processed.args[0], 'arg');
},
+ 'Opt keys are case insensitive': function() {
+ var processed = utilities.processARGV(['', '', 'atask', 'CaMel=b', 'c=HumPs', 'third=alongerthing']);
+ assert.equal(processed.opts.camel, 'b');
+ assert.equal(processed.opts.c, 'HumPs');
+ assert.equal(processed.opts.third, 'alongerthing');
+ },
+ 'Opt values are case sensitive': function() {
+ var processed = utilities.processARGV(['', '', 'atask', 'CaMel=b']);
+ assert.equal(processed.opts.camel, 'b');
+ },
+ 'Args are case sensitive': function() {
+ var processed = utilities.processARGV(['', '', 'atask', 'HumPs']);
+ assert.equal(processed.args[0], 'HumPs');
+ },
'Multiple opts work': function() {
var processed = utilities.processARGV(['', '', 'atask', 'a=b', 'c=100', 'third=alongerthing']);
assert.equal(processed.opts.a, 'b');
Please sign in to comment.
Something went wrong with that request. Please try again.