diff --git a/core/scripts/dev/commit-code-check.sh b/core/scripts/dev/commit-code-check.sh index 7252c9364bd..4e1211b2657 100755 --- a/core/scripts/dev/commit-code-check.sh +++ b/core/scripts/dev/commit-code-check.sh @@ -123,8 +123,31 @@ fi; # run and all dependencies are updated. FINAL_STATUS=0 -# Check all files for spelling in one go for better performance. +DEPENDENCIES_NEED_INSTALLING=0 +# Ensure PHP development dependencies are installed. +# @todo https://github.com/composer/composer/issues/4497 Improve this to +# determine if dependencies in the lock file match the installed versions. +# Using composer install --dry-run is not valid because it would depend on +# user-facing strings in Composer. +if ! [[ -f 'vendor/bin/phpcs' ]]; then + printf "Drupal's PHP development dependencies are not installed. Run 'composer install' from the root directory.\n" + DEPENDENCIES_NEED_INSTALLING=1; +fi + cd "$TOP_LEVEL/core" + +# Ensure JavaScript development dependencies are installed. +yarn check -s 2>/dev/null +if [ "$?" -ne "0" ]; then + printf "Drupal's JavaScript development dependencies are not installed. Run 'yarn install' inside the core directory.\n" + DEPENDENCIES_NEED_INSTALLING=1; +fi + +if [ $DEPENDENCIES_NEED_INSTALLING -ne 0 ]; then + exit 1; +fi + +# Check all files for spelling in one go for better performance. yarn run -s spellcheck -c $TOP_LEVEL/core/.cspell.json $ABS_FILES if [ "$?" -ne "0" ]; then # If there are failures set the status to a number other than 0.