#!/bin/bash function tidy { rm -vf {./,tests/,src/{./,AntiCSRF/,Clock/,Hash/,Logger/,Request/,Required/,RFC/,Session/,URI/,Workflow/}}*~ rm -vf {./,tests/,src/{./,AntiCSRF/,Clock/,Hash/,Logger/,Request/,Required/,RFC/,Session/,URI/,Workflow/}}#*# } function clean { if [[ ! -d "vendor/" ]]; then echo "No vendor/ folder to remove." else echo "Removing ./vendor/ ..." rm -rf "vendor/" echo "Done" fi rm -fv "composer.lock" } function update { composer update rv=$? if [[ $rv > 0 ]]; then composer dumpautoload -v fi return $rv } function update_if_no_vendors { if [[ ! -d "vendor/" ]]; then update if [[ $? -ne 0 ]]; then exit $? fi fi } if [[ $# -ne 1 ]]; then echo "This script requires a verb." echo "VERBS:" echo " update - Update dependencies with composer" echo " test - If no vendor/ folder Update, then run phpunit tests." echo " testloud - If no vendor/ folder Update, then run phpunit tests with all" echo " optional output" echo " clean - Remove all buildfiles and editor artifacts." echo " tidy - Remove all editor artifacts." echo "" echo "For style points, you might consider targeting these with git-hooks" fi cmd=$1 if [[ $cmd == "update" ]]; then update exit $? elif [[ $cmd == "test" ]]; then update_if_no_vendors ./vendor/bin/phpunit --testdox --stderr tests exit $? elif [[ $cmd == "testloud" ]]; then update_if_no_vendors ./vendor/bin/phpunit --testdox --stderr --display-deprecations --display-errors --display-notices --display-warnings tests elif [[ $cmd == "tidy" ]]; then tidy elif [[ $cmd == "clean" ]]; then tidy && clean else echo "Unrecognized verb: ${cmd}" exit 1 fi exit 0