diff --git a/commands/web/xb-cspell b/commands/web/xb-cspell index 285d18b..0dd61b6 100755 --- a/commands/web/xb-cspell +++ b/commands/web/xb-cspell @@ -2,12 +2,27 @@ ## #ddev-generated ## Description: Check for spelling errors with cspell. -## Usage: xb-cspell -## Example: ddev xb-cspell # Check for spelling errors.\nddev cspell # Same, via alias. +## Usage: xb-cspell [staged] +## Example: ddev xb-cspell # Check for spelling errors across the module.\nddev xb-cspell staged # Check only files staged for commit. ## Aliases: cspell,spell ## ExecRaw: false ## Flags: [] +## AutocompleteTerms: ["staged"] cd "$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT/modules/contrib/canvas" || exit 1 -npm run lint:cspell +case "$1" in + "staged") + staged_files=$(git diff --cached --name-only --diff-filter=ACMR) + if [ -z "$staged_files" ]; then + echo "Nothing staged; skipping cspell." + exit 0 + fi + npx cspell --no-progress --no-must-find-files $staged_files + ;; + "") npm run lint:cspell ;; + *) + echo "Invalid argument: $1" + exit 1 + ;; +esac