-
-
Save dakala/d3c0f9ee1d13011f8fbd80a13b8c6a8f to your computer and use it in GitHub Desktop.
#!/bin/sh | |
# Install drupal/coder | |
composer global require drupal/coder | |
# Register Drupal and DrupalPractice Standard with PHPCS | |
phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer | |
# Colorise output | |
phpcs --config-set colors 1 | |
# Go home | |
cd ~ | |
# Add aliases to .bashrc | |
sed -i '0,/alias/s//\nalias drupalcs="phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"\nalias drupalbp="phpcs --standard=DrupalPractice --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"\nalias drupalcbf="phpcbf --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"\n&/' .bashrc | |
# Refresh | |
source .bashrc |
Provided you have aliases defined in your .bashrc:
sed -i '0,/alias/s//\nalias drupalcs="phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"\nalias drupalbp="phpcs --standard=DrupalPractice --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"\nalias drupalcbf="phpcbf --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"\n&/' .bashrc
works on linux
sed -i "" -e '0,/alias/s//\nalias drupalcs="phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"\nalias drupalbp="phpcs --standard=DrupalPractice --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"\nalias drupalcbf="phpcbf --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"\n&/' .bashrc
should work on mac
The last sed command doesn't work on Mac. Best to add the aliases to your .bash_profile or .bashrc and source the file:
alias drupalcs="phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt'"
alias drupalbp="phpcs --standard=DrupalPractice --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"
alias drupalcbf="phpcbf --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt,md'"
drupalcs FILENAME - outputs Drupal standard coding issues found in FILENAME
drupalcbf FILENAME - automatically fixes most Drupal coding issues found in FILENAME (sometimes not all can be fixed by PHPCBF)
drupalbp FILENAME - checks FILENAME for issues that don't follow Drupal best practice