I'm writing a little pre-commit hook to check for debug code this works well when using:
FORBIDDEN='console.log'
but when I change to:
FORBIDDEN='die(|console.log(|print_r('
it fails to catch anything.
FULL CODE:
FILES_PATTERN='(\..+)?$'
FORBIDDEN='die(|console.log(|print_r('
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
xargs grep -E --with-filename -n $FORBIDDEN | \
grep -v '//';
Not sure if its regex or something else
尝试转义括号:
FORBIDDEN='die\(|console.log\(|print_r\('
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.