Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mustafatoker/481014e4e5a38a87fdcc5642c01f37d9 to your computer and use it in GitHub Desktop.
Save mustafatoker/481014e4e5a38a87fdcc5642c01f37d9 to your computer and use it in GitHub Desktop.
A little bash script to run tests when a file has been changed
#!/usr/bin/env bash
function pw {
# Register the command you want to run when changes are detected here
run="clear && printf '\e[3J' && vendor/bin/phpunit"
# Retrieve the custom argments. If none are provided, default to "tests"
[[ -n $@ ]] && args=$@ || args="tests"
# Run the command first...
eval "$run $args"
# ...then start watching for changes—and run on change
watchman-make -p 'src/**/*.php' 'tests/**/*.php' \
--make=$run \
-t "$args"
}
@mustafatoker
Copy link
Author

  1. Install via https://facebook.github.io/watchman/
  2. Copy the function below into "nano ~/.bashrc" then run this command -> "source ~/.bashrc"
  3. Go to your tests suit and run "pw" command. No longer need to run "vendor/bin/phpunit" command on every change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment