File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ PROJECT=` php -r " echo dirname(dirname(realpath('$0 ')));" `
3
+ STAGED_FILES_CMD=` git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\ .php`
4
+ echo $PROJECT
5
+ # Determine if a file list is passed
6
+ if [ " $# " -eq 1 ]
7
+ then
8
+ oIFS=$IFS
9
+ IFS='
10
+ '
11
+ SFILES=" $1 "
12
+ IFS=$oIFS
13
+ fi
14
+
15
+ SFILES=${SFILES:- $STAGED_FILES_CMD }
16
+
17
+ echo " Checking PHP Lint..."
18
+ for FILE in $SFILES
19
+ do
20
+ php -l -d display_errors=0 $PROJECT /$FILE
21
+ if [ $? != 0 ]
22
+ then
23
+ echo -e " \033[41m" Fix the error before commit." \033[0m"
24
+ exit 1
25
+ fi
26
+ FILES=" $FILES $PROJECT /$FILE "
27
+ done
28
+
29
+ if [ " $FILES " != " " ]
30
+ then
31
+
32
+ echo -e " \033[0;32m" Running Code Sniffer..." \033[0m"
33
+ ./vendor/bin/phpcs --standard=EcgM2,PSR2,Magento2 --encoding=utf-8 -p $FILES
34
+
35
+ if [ $? != 0 ]
36
+ then
37
+ echo -e " \033[41m" Fix the error before commit." \033[0m"
38
+ exit 1
39
+ fi
40
+
41
+ echo -e " \033[0;32m" Recovering your stashed code..." \033[0m"
42
+
43
+ fi
44
+
45
+ exit $?
Original file line number Diff line number Diff line change 4
4
"homepage" : " https://github.com/magento-ecg/coding-standard" ,
5
5
"license" : " MIT" ,
6
6
"type" : " phpcodesniffer-standard" ,
7
+ "version" : " 4.0" ,
7
8
"authors" : [
8
9
{
9
10
"name" : " Magento Expert Consulting Group" ,
You can’t perform that action at this time.
0 commit comments