Skip to content

Instantly share code, notes, and snippets.

@nfreear
Created November 22, 2017 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfreear/de698530451c248798a7b33617ff582b to your computer and use it in GitHub Desktop.
Save nfreear/de698530451c248798a7b33617ff582b to your computer and use it in GitHub Desktop.
A Git pre-commit hook, to run lint and tests, for PHP and/or Node.JS projects | © Nick Freear | http://githooks.com
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit". Copy to "../.git/hooks"
# https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
# http://githooks.com
#
# © Nick Freear, 22-November-2017.
#
echo
echo Pre-commit hook!
echo ' > composer validate'
echo ' > composer test'
# PHP projects.
composer validate
composer build
composer test
# Javascript (Node.JS) projects.
npm run build
npm test
# echo Exit: 1
# exit 1
# End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment