From 7ab83718711fbb24caeed5dad0f47668bb2cae55 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 12 Sep 2023 15:19:04 +0100
Subject: [PATCH] Issue #3386607 by alexpott: Improve spell checking in
 commit-code-check.sh

---
 core/package.json                     |  2 +-
 core/scripts/dev/commit-code-check.sh | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/core/package.json b/core/package.json
index 321ecdb74a82..42580071317c 100644
--- a/core/package.json
+++ b/core/package.json
@@ -22,7 +22,7 @@
     "prettier": "prettier --write \"./**/*.js\"",
     "spellcheck": "cspell -c .cspell.json",
     "spellcheck:make-drupal-dict": "rm -f misc/cspell/dictionary.txt && touch misc/cspell/dictionary.txt && yarn -s spellcheck:core --unique --words-only | perl -Mopen=locale -pe '$_=lc$_' | LC_ALL=en_US.UTF-8 tr -d \\\\\\\\ | LC_ALL=C sort -u -o misc/cspell/dictionary.txt",
-    "spellcheck:core": "cspell -c .cspell.json --no-progress --root .. \"core/**/*\" \"composer/**/*\" \"composer.json\"",
+    "spellcheck:core": "cspell -c .cspell.json --root .. \"core/**/*\" \"composer/**/*\" \"composer.json\"",
     "vendor-update": "node ./scripts/js/vendor-update.js",
     "watch:ckeditor5": "webpack --config ./modules/ckeditor5/webpack.config.js --watch",
     "build:ckeditor5": "webpack --config ./modules/ckeditor5/webpack.config.js",
diff --git a/core/scripts/dev/commit-code-check.sh b/core/scripts/dev/commit-code-check.sh
index a22a7808afb9..2d47e0f950c5 100755
--- a/core/scripts/dev/commit-code-check.sh
+++ b/core/scripts/dev/commit-code-check.sh
@@ -176,7 +176,7 @@
     CKEDITOR5_PLUGINS_CHANGED=1;
   fi;
 
-  if [[ $FILE == "core/misc/cspell/dictionary.txt" ]]; then
+  if [[ $FILE == "core/misc/cspell/dictionary.txt" || $FILE == "core/.cspell.json" ]]; then
     CSPELL_DICTIONARY_FILE_CHANGED=1;
   fi
 done
@@ -215,13 +215,15 @@
   exit 1;
 fi
 
-# Run spellcheck:core when cspell files are changed.
 # Check all files for spelling in one go for better performance.
 if [[ $CSPELL_DICTIONARY_FILE_CHANGED == "1" ]] ; then
   printf "\nRunning spellcheck on *all* files.\n"
-  yarn run -s spellcheck:core --no-must-find-files --root $TOP_LEVEL $ABS_FILES
+  yarn run -s spellcheck:core --no-must-find-files --no-progress
 else
-  yarn run -s spellcheck --no-must-find-files --root $TOP_LEVEL $ABS_FILES
+  # Check all files for spelling in one go for better performance. We pipe the
+  # list files in so we obey the globs set on the spellcheck:core command in
+  # core/package.json.
+  echo "${ABS_FILES}" | tr ' ' '\n' | yarn run -s spellcheck:core --no-must-find-files --file-list stdin
 fi
 
 if [ "$?" -ne "0" ]; then
-- 
GitLab