« get me outta code hell

find: indicate which letters mismatch capitalization - 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>2025-06-10 09:57:22 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-06-10 09:57:22 -0300
commit825606760247aa2a5d6fd08f5e66bf763248a85b (patch)
tree73401ac640399bc1c5604d69d310e8fff822e40c /src/find.js
parent77da50cb298a9e8072de9872c5c5090ab89c85c6 (diff)
find: indicate which letters mismatch capitalization
Diffstat (limited to 'src/find.js')
-rw-r--r--src/find.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/find.js b/src/find.js
index e7471df9..d5ef400d 100644
--- a/src/find.js
+++ b/src/find.js
@@ -124,6 +124,25 @@ function oopsNameCapitalizationMismatch(mode, {
   matchingName,
   matchedName,
 }) {
+  if (matchingName.length === matchedName.length) {
+    let a = '', b = '';
+    for (let i = 0; i < matchingName.length; i++) {
+      if (
+        matchingName[i] === matchedName[i] ||
+        matchingName[i].toLowerCase() !== matchingName[i].toLowerCase()
+      ) {
+        a += matchingName[i];
+        b += matchedName[i];
+      } else {
+        a += colors.bright(colors.red(matchingName[i]));
+        b += colors.bright(colors.green(matchedName[i]));
+      }
+    }
+
+    matchingName = a;
+    matchedName = b;
+  }
+
   return warnOrThrow(mode,
     `Provided capitalization differs from the matched name. Please resolve:\n` +
     `- provided: ${matchingName}\n` +