diff options
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 |
commit | 825606760247aa2a5d6fd08f5e66bf763248a85b (patch) | |
tree | 73401ac640399bc1c5604d69d310e8fff822e40c | |
parent | 77da50cb298a9e8072de9872c5c5090ab89c85c6 (diff) |
find: indicate which letters mismatch capitalization
-rw-r--r-- | src/find.js | 19 |
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` + |