Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy path.pre-commit
More file actions
Latest commit
executable file
·34 lines (28 loc) · 929 Bytes
/
Copy path.pre-commit
File metadata and controls
executable file
·34 lines (28 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
export PATH="$PATH:$HOME/.composer/vendor/bin"
if!command -v php-cs-fixer &> /dev/null;then
echo"php-cs-fixer could not be found"
echo"It must be installed globally with composer: composer global require friendsofphp/php-cs-fixer"
echo"Make sure it's in your \$PATH"
exit 1
fi
pm4dir="$(dirname "$(readlink -f "$0")")"
files=$(git status --porcelain=v2 | grep -E '^\d [AM].*\.php$'| cut -d '' -f 9)
errors=()
if [ -n"$files" ];then
whileread file;do
echo"Checking $file"
php-cs-fixer fix --dry-run --verbose "$file"2> /dev/null
if [ $?-ne 0 ];then
errors+=("$file")
fi
done<<<"$files"
fi
if [ ${#errors[@]}-gt 0 ];then
echo""
echo"php-cs-fixer failed for files: ${errors[@]}"
echo""
echo"You can attempt to fix these automatically by running 'php-cs-fixer fix [file]'"
echo""
exit 1
fi