Fix: Correctly check synonyms when checking if an option is provided by the user

This commit is contained in:
n loewen 2023-09-02 16:40:51 -04:00
parent ddef1d82dc
commit 4dec08afbc
1 changed files with 7 additions and 3 deletions

View File

@ -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;
}
}