« get me outta code hell

Merge branch 'preview' into track-data-cleanup - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/find.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-19 10:00:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-19 10:00:21 -0300
commitc6c1a6be4ee817c65ccc994cd6ae68a835aa406e (patch)
tree23e07252b71329bf99aad400aa0ca93eb59ba532 /src/find.js
parentfd102ee597e2ad2ba8f0950ce1a16fd34029963d (diff)
parentfdd8f355bfe0992fc340f800297df524276b1946 (diff)
Merge branch 'preview' into track-data-cleanup
Diffstat (limited to 'src/find.js')
-rw-r--r--src/find.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/find.js b/src/find.js
index 5ad8dae..66f705e 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: ${colors.red(ref)} -> ${colors.green(thing.name)}`
-    );
+    warnOrThrow(mode,
+      `Bad capitalization: ${colors.red(ref)} -> ${colors.green(thing.name)}`);
   }
 
   return thing;