Skip to content

Instantly share code, notes, and snippets.

@stretchkennedy
Created May 10, 2018 04:52
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 stretchkennedy/29c221eaee8fbddabc7c1a1b17095b84 to your computer and use it in GitHub Desktop.
Save stretchkennedy/29c221eaee8fbddabc7c1a1b17095b84 to your computer and use it in GitHub Desktop.
Check the age of all your js files before committing (using husky)
#!/bin/bash
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd)"
FILES="$(find "$DIR"/src -type f -name '*.js' -not -name '*.test.js')"
IS_OLDER=false
for f in $FILES; do
if [[ "$f" -nt bundle.js ]]; then
echo "$f is newer than bundle.js"
IS_OLDER=true
fi
done
if [[ $IS_OLDER = true ]]; then
echo
echo "found source files newer than bundle.js (did you forget to run 'npm build'?)"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment