mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(util) checkArgs: add length check first
This commit is contained in:
parent
f56a175101
commit
1f810293ff
1 changed files with 11 additions and 9 deletions
20
lib/util.js
20
lib/util.js
|
|
@ -131,17 +131,19 @@
|
|||
msg = '',
|
||||
i = 0,
|
||||
n = names.length,
|
||||
isLength = n === argsParam.length,
|
||||
template = '{{ name }} coud not be empty!';
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (!argsParam[i]) {
|
||||
msg = Util.render(template, {
|
||||
name: names[i]
|
||||
});
|
||||
|
||||
error = new Error(msg);
|
||||
throw(error);
|
||||
}
|
||||
if (!isLength)
|
||||
for (i = 0; i < n; i++)
|
||||
if (!argsParam[i]) {
|
||||
msg = Util.render(template, {
|
||||
name: names[i]
|
||||
});
|
||||
|
||||
error = new Error(msg);
|
||||
throw(error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue