Commit e7cbdb85 authored by catch's avatar catch
Browse files

Issue #3212579 by quietone, Spokje: Spell check all files if dictionary.txt changes

(cherry picked from commit cdd3e5ef)
parent de746009
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 --root .. \"core/**/*\" \"composer/**/*\" \"composer.json\"",
    "spellcheck:core": "cspell -c .cspell.json --no-progress --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",
+15 −1
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@
# it is used to make sure the compiled JS is valid.
CKEDITOR5_PLUGINS_CHANGED=0

# This variable will be set to when the dictionary has changed.
CSPELL_DICTIONARY_FILE_CHANGED=0

# Build up a list of absolute file names.
ABS_FILES=
for FILE in $FILES; do
@@ -172,6 +175,10 @@
  if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.js$ ]] && [[ $FILE =~ ^core/modules/ckeditor5/js/build || $FILE =~ ^core/modules/ckeditor5/js/ckeditor5_plugins ]]; then
    CKEDITOR5_PLUGINS_CHANGED=1;
  fi;

  if [[ $FILE == "core/misc/cspell/dictionary.txt" ]]; then
    CSPELL_DICTIONARY_FILE_CHANGED=1;
  fi
done

# Exit early if there are no files.
@@ -208,8 +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
else
  yarn run -s spellcheck --no-must-find-files --root $TOP_LEVEL $ABS_FILES
fi

if [ "$?" -ne "0" ]; then
  # If there are failures set the status to a number other than 0.
  FINAL_STATUS=1