Comparing version 1.0.8 to 1.0.9
@@ -233,2 +233,11 @@ const Class = require('cify').Class; | ||
/** | ||
* 是否包含重复字符 | ||
**/ | ||
_hasRepeatChar: function (str) { | ||
if (utils.isNull(str)) return false; | ||
var array = str.split(''); | ||
return utils.unique(array).length != array.length; | ||
}, | ||
/** | ||
* 解析组合短参数 | ||
@@ -241,3 +250,7 @@ **/ | ||
if (this._options[token]) return; //如果是一个明确存在的 option | ||
var shortOptions = this._trimOptionName(token).split('').map(function (char) { | ||
var trimedName = this._trimOptionName(token); | ||
if (trimedName.length < 2 || this._hasRepeatChar(trimedName)) { | ||
return invalidOptions.push(token); | ||
} | ||
var shortOptions = trimedName.split('').map(function (char) { | ||
return '-' + char; | ||
@@ -249,4 +262,3 @@ }); | ||
if (!allExsits) { | ||
invalidOptions.push(token); | ||
return; | ||
return invalidOptions.push(token); | ||
} | ||
@@ -253,0 +265,0 @@ //将分解后的短参插入 |
{ | ||
"name": "cmdline", | ||
"rawName": "cmdline", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "cmdline is a process.argv parser", | ||
@@ -39,3 +39,3 @@ "main": "./lib/index.js", | ||
"cify": "^1.0.0", | ||
"ntils": "^1.0.1" | ||
"ntils": "^1.0.2" | ||
}, | ||
@@ -46,2 +46,2 @@ "devDependencies": { | ||
} | ||
} | ||
} |
13927
459
Updatedntils@^1.0.2