Comparing version 0.0.2 to 0.0.3
@@ -5,2 +5,6 @@ # commandos Change Log | ||
## [0.0.3] - Dec 23, 2017 | ||
* Fixed: `ReferenceError: extractProperty is not defined` | ||
## [0.0.2] - Dec 22, 2017 | ||
@@ -7,0 +11,0 @@ |
@@ -15,3 +15,3 @@ { | ||
"name": "commandos", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "index.js", | ||
@@ -23,3 +23,4 @@ "keywords": [ | ||
"options", | ||
"dos" | ||
"dos", | ||
"getopts" | ||
], | ||
@@ -26,0 +27,0 @@ "homepage": "https://github.com/YounGoat/nodejs.commandos", |
10
parse.js
@@ -263,2 +263,3 @@ 'use strict'; | ||
// *names* includes formal name and alias. | ||
const names = [ column.name ].concat(column.alias); | ||
@@ -294,11 +295,2 @@ const names_lc = caseSensitive ? null : names.map(name => name.toLowerCase()); | ||
if (!found && column.alias) { | ||
// If property not found, try alias if defined. | ||
let alias = column.alias instanceof Array ? column.alias : [ column.alias ]; | ||
for (let i = 0; i < alias.length && !found; i++) { | ||
// If there are more than one alias, the former in definition is prior. | ||
found = extractProperty(alias[i], propertyName); | ||
} | ||
} | ||
if (found && !column.nullable && typeof value == 'boolean') { | ||
@@ -305,0 +297,0 @@ throw new Error(`option need to be valued: ${names_notation}`); |
@@ -209,5 +209,16 @@ 'use strict'; | ||
]; | ||
let settings = { overwrite: true, options }; | ||
assert.throws(() => parseCommand(cmdtext, settings)); | ||
assert.throws(() => parseCommand(cmdtext, options)); | ||
}); | ||
it('required disabled', () => { | ||
let cmdtext = 'foo'; | ||
let options = [ | ||
{ | ||
name: 'version', | ||
alias: 'v', | ||
required: false, | ||
} | ||
]; | ||
parseCommand(cmdtext, options); | ||
}); | ||
}); | ||
@@ -214,0 +225,0 @@ |
534
24857