forked from hootsuite/pre-commit-php
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45b0f40
commit c864643
Showing
3 changed files
with
84 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
################################################################################ | ||
# | ||
# Bash PHPStan | ||
# | ||
# This script fails if the PHPStan output has the word "ERROR" in it. | ||
# | ||
# Exit 0 if no errors found | ||
# Exit 1 if errors were found | ||
# | ||
# Requires | ||
# - php | ||
# | ||
# Arguments | ||
# See: https://phpstan.org/user-guide/command-line-usage | ||
# | ||
################################################################################ | ||
|
||
# Plugin title | ||
title="PHPStan" | ||
|
||
# Possible command names of this tool | ||
local_command="phpstan.phar" | ||
vendor_command="vendor/bin/phpstan" | ||
global_command="phpstan" | ||
|
||
# Print a welcome and locate the exec for this tool | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
source $DIR/helpers/colors.sh | ||
source $DIR/helpers/formatters.sh | ||
source $DIR/helpers/welcome.sh | ||
source $DIR/helpers/locate.sh | ||
|
||
command_files_to_check="${@:2}" | ||
command_args=$1 | ||
command_to_run="${exec_command} analyse --no-progress ${command_args} ${command_files_to_check}" | ||
|
||
echo -e "${bldwht}Running command ${txtgrn} ${exec_command} analyse ${command_args} ${txtrst}" | ||
hr | ||
command_result=`eval $command_to_run` | ||
if [[ $command_result =~ ERROR ]] | ||
then | ||
hr | ||
echo -en "${bldmag}Errors detected by ${title}... ${txtrst} \n" | ||
hr | ||
echo "$command_result" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |