Finding project files containing console.log()

Found this little snippet online and modified for my own purposes. The goal was to find all template and PHP files containing console.log() operations, left in by other developers and programmers for debugging purposes. You don't want to have these files in your production environment, therefore before committing your code you could (with little modifications) add this to your pre-commit git hook and refuse commit if certain files contain console.log().

egrep -lir --include=*.{php,phtml,tpl} "(console\.log\()" .

Following command will find all PHP, PHTML and TPL files in current folder which contain string console.log(
It will simply list all the files. You could pipe it with " | wc -l" to get counts.


Comments

Popular posts from this blog

Stubbing and Mocking Static Methods with PHPUnit

Enable HTTP/2 Support in AWS ELB

How To Attach Your EBS volume to multiple EC2 instances