Skip to content
Snippets Groups Projects

Resolve #3345071 "Pierre proposal"

26 files
+ 1146
12
Compare changes
  • Side-by-side
  • Inline
Files
26
+ 66
0
 
#!/usr/bin/env bash
 
 
## Run PHP Code Sniffer Commands
 
##
 
## This command will allow for running Code Sniffer commands
 
## to help make sure is to coding standards.
 
##
 
## Running PHPCS
 
## fin phpcs cs "[directory name]"
 
##
 
## Running PHPCBF
 
## fin phpcs cbf "[directory name]"
 
##
 
## Usage:
 
## cs Run PHPCS
 
## cbf Run PHPCBF
 
 
STANDARDS=""
 
 
if [[ -n "${PHPCS_STANDARDS}" ]]; then
 
STANDARDS="${PHPCS_STANDARDS}"
 
fi
 
 
if [[ -n "${PHPCS_EXTENSIONS}" ]]; then
 
EXTENSIONS="${PHPCS_EXTENSIONS}"
 
fi
 
 
if [[ -f "${PROJECT_ROOT}/${DOCROOT}/sites/default/settings.php" ]] || [[ -f "${PROJECT_ROOT}/${DOCROOT}/sites/default/default.settings.php" ]]; then
 
STANDARDS="${STANDARDS:-"Drupal,DrupalPractice"}"
 
EXTENSIONS="${EXTENSIONS:-"php,module,inc,install,test,profile,theme,css,info,txt,md"}";
 
elif [[ -f "${PROJECT_ROOT}/${DOCROOT}/wp-config.php" ]]; then
 
STANDARDS="${STANDARDS:-"WordPress"}"
 
EXTENSIONS="${EXTENSIONS:-"php"}"
 
fi
 
 
COMMAND=""
 
 
case "$1" in
 
cs)
 
shift
 
COMMAND="/var/vendor/phpcs"
 
;;
 
cbf)
 
shift
 
COMMAND="phpcbf"
 
;;
 
*)
 
fin help phpcs
 
exit
 
;;
 
esac
 
 
# If standard flag is used remove our default.
 
STANDARD_OPT="--standard=\"${STANDARDS}\""
 
if [[ "$@" =~ "--standard=" ]]; then
 
STANDARD_OPT=""
 
fi
 
 
# If extension flag is used remove our default.
 
EXTENSION_OPT="--extensions=\"${EXTENSIONS}\""
 
if [[ "$@" =~ "--extensions=" ]]; then
 
EXTENSION_OPT=""
 
fi
 
print "$COMMAND $STANDARD_OPT $EXTENSION_OPT $@"
 
# run the command in the container.
 
fin exec "$COMMAND $STANDARD_OPT $EXTENSION_OPT $@"
Loading