diff options
Diffstat (limited to 'src/find.js')
-rw-r--r-- | src/find.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/find.js b/src/find.js index b8230800..966629e3 100644 --- a/src/find.js +++ b/src/find.js @@ -80,17 +80,19 @@ function matchDirectory(ref, data) { } function matchName(ref, data, mode) { - const matches = data.filter( - ({name}) => name.toLowerCase() === ref.toLowerCase() - ); + const matches = + data + .filter(({name}) => name.toLowerCase() === ref.toLowerCase()) + .filter(thing => + (Object.hasOwn(thing, 'alwaysReferenceByDirectory') + ? !thing.alwaysReferenceByDirectory + : true)); if (matches.length > 1) { - return warnOrThrow( - mode, + return warnOrThrow(mode, `Multiple matches for reference "${ref}". Please resolve:\n` + - matches.map((match) => `- ${inspect(match)}\n`).join('') + - `Returning null for this reference.` - ); + matches.map(match => `- ${inspect(match)}\n`).join('') + + `Returning null for this reference.`); } if (matches.length === 0) { @@ -100,10 +102,8 @@ function matchName(ref, data, mode) { const thing = matches[0]; if (ref !== thing.name) { - warnOrThrow( - mode, - `Bad capitalization: ${color.red(ref)} -> ${color.green(thing.name)}` - ); + warnOrThrow(mode, + `Bad capitalization: ${color.red(ref)} -> ${color.green(thing.name)}`); } return thing; |