From 37ebdabc201bd8fa55db0d064acdd4c5ca366231 Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 28 Jun 2019 02:21:55 -0300 Subject: [PATCH] Improving Makefile and PHPUNIT dependency on composer.json --- Makefile | 4 +++- composer.json | 3 +-- pre-push.sh | 12 +++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4b49b48..39a3625 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ install: - composer update + command -v composer && composer install || echo "Please, install Composer to use tests" + command -v phpunit || command -v composer && composer require --dev phpunit/phpunit ^8 chmod +x ./pre-push.sh mkdir -p .git/hooks ln -fs ../../pre-push.sh .git/hooks/pre-push uninstall: rm -f ./.git/hooks/pre-push + if [ -d "./vendor/phpunit" ] ; then composer remove --dev phpunit/phpunit; fi diff --git a/composer.json b/composer.json index 3918706..026d73f 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,5 @@ } ], "require-dev": { - "phpunit/phpunit": "^8.2" - } + } } diff --git a/pre-push.sh b/pre-push.sh index 490abf6..3db4291 100755 --- a/pre-push.sh +++ b/pre-push.sh @@ -1 +1,11 @@ -./vendor/phpunit/phpunit/phpunit --bootstrap vendor/autoload.php tests --testdox --color +params="--bootstrap vendor/autoload.php tests --testdox --color" + +if [ $(command -v phpunit) ]; then + phpunit $params +else + if [ -d ./vendor/phpunit ]; then + ./vendor/phpunit/phpunit/phpunit $params + else + echo "Please, run 'make install' or install phpunit globally to run the tests" + fi +fi