Skip to content

Instantly share code, notes, and snippets.

@djanowski
Created January 13, 2017 22:28
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 djanowski/6b11aca65cbb43bfafcad66ed13148d4 to your computer and use it in GitHub Desktop.
Save djanowski/6b11aca65cbb43bfafcad66ed13148d4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Monitors your tree and runs tests when anything changes.
#
# `make`, `yarn test`, etc. automatically detected.
#
# $ autotest
#
# Run a specific command on changes:
#
# $ autotest mocha test/foo_test.js
#
trap exit INT
if [[ -f package.json ]]; then
BUILD=${@:-yarn test}
elif [[ -f Makefile ]]; then
BUILD=${@:-make}
else
echo "Don't know what command to run. Try: autotest [command]" >&2
exit 1
fi
while true; do
ag -l | td entr -rd sh -c "echo ===; $BUILD"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment