Skip to content

Instantly share code, notes, and snippets.

@jmlagace
Last active January 21, 2022 16:24
Show Gist options
  • Save jmlagace/fc294d41c372fda58efedd5b671e1145 to your computer and use it in GitHub Desktop.
Save jmlagace/fc294d41c372fda58efedd5b671e1145 to your computer and use it in GitHub Desktop.
Language Check Scripts

Language Check Scripts

Quickly scan a folder structure to validate all files of a specific language to validate syntax.

By default the scripts will checks all the files. By specifying the option recent, it only checks the files that have been updated within the last 240 minutes

The script in this gist

#!/bin/sh
if [ "$1" = "recent" ]; then
ADDITONAL_OPTIONS="-mmin -240"
else
ADDITONAL_OPTIONS=""
fi
find . $ADDITONAL_OPTIONS -name "*.php" -print0 | xargs -0 -n1 -P10 php -l | grep -v 'No syntax errors'
if [ "$?" -eq "0" ]; then
exit 1
else
exit 0
fi
#!/bin/sh
if [ "$1" = "recent" ]; then
ADDITONAL_OPTIONS="-mmin -240"
else
ADDITONAL_OPTIONS=""
fi
find . $ADDITONAL_OPTIONS -name "*.rb" -print0 | xargs -0 -n1 -P10 ruby -c | grep -v 'Syntax OK'
if [ "$?" -eq "0" ]; then
exit 1
else
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment