Fix: Correctly check synonyms when checking if an option is provided by the user
This commit is contained in:
parent
ddef1d82dc
commit
4dec08afbc
10
opter.js
10
opter.js
|
|
@ -51,8 +51,8 @@ module.exports = class Opts {
|
|||
const name = stripDashes(nameWithDashes);
|
||||
if (name in this.opts) return true;
|
||||
if (name in this.synonyms) {
|
||||
let syns = this.synonyms[name];
|
||||
let hits = syns.filter(s => s in this.opts ).length;
|
||||
const syns = this.synonyms[name];
|
||||
const hits = syns.filter(s => s in this.opts ).length;
|
||||
if (hits > 0) { return true; }
|
||||
}
|
||||
throw new Error(errorMessage || defaultErrorMessages.missingRequiredOption(nameWithDashes));
|
||||
|
|
@ -94,7 +94,11 @@ module.exports = class Opts {
|
|||
contains(nameWithDashes) {
|
||||
const name = stripDashes(nameWithDashes);
|
||||
if (name in this.opts) return true;
|
||||
if (name in this.synonyms) return true; // FIXME
|
||||
if (name in this.synonyms) {
|
||||
const syns = this.synonyms[name];
|
||||
const hits = syns.filter(s => s in this.opts ).length;
|
||||
if (hits > 0) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue