Skip to content

Instantly share code, notes, and snippets.

@djanowski
Last active February 1, 2016 20:17
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/22712edfd9a03980688a to your computer and use it in GitHub Desktop.
Save djanowski/22712edfd9a03980688a to your computer and use it in GitHub Desktop.
ag -l + entr = autotest!
#!/usr/bin/env bash
# Monitors your tree and runs tests when anything changes.
#
# Run `make`, `npm 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=${@:-npm 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 | entr -rcd sh -c "$BUILD"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment