Created
June 1, 2016 15:50
-
-
Save kill9zombie/81b684a0f83f2402585bb06ba69cc4ea to your computer and use it in GitHub Desktop.
Run Elixir's 'mix test' in a loop, triggered by file changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mix_test_loop --description "Run 'mix test' in a loop, triggered by file changes" | |
# file: ~/.config/fish/functions/mix_test_loop.fish | |
# | |
# Run 'mix test' in a loop. We'll only update the screen when an elixir file | |
# changes. | |
# | |
# usage: mix_test_loop 5 | |
# | |
# Where the second argument is the number of seconds to wait | |
# before starting the loop again. Defaults to 5 seconds. | |
# | |
function _files_mtime | |
echo (stat --printf '{%n, %Y}' (find -regex '.+\.ex[s]*$')) | |
end | |
# Set a sleep default | |
if test -n "$argv" | |
set -g mix_test_loop_sleep $argv | |
else | |
set -g mix_test_loop_sleep 5 | |
end | |
# Start the main loop | |
while true | |
if test -n (echo $mix_test_loop_files) | |
if test $mix_test_loop_files != (_files_mtime) | |
clear | |
mix test | |
set -g mix_test_loop_files (_files_mtime) | |
end | |
else | |
set -g mix_test_loop_files (_files_mtime) | |
clear | |
mix test | |
end | |
sleep (echo $mix_test_loop_sleep) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment