Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.