Created
April 21, 2019 22:07
-
-
Save drosenstark/a9ba254800b04a6a8cc66182b8bfaf8c to your computer and use it in GitHub Desktop.
Watch and Swift file and run it on change
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
#!/bin/sh | |
# swiftWatchAndRun | |
if [ $# -ne 1 ]; then | |
echo "Use like this:" | |
echo " $0 filename-to-watch" | |
exit 1 | |
fi | |
if which fswatch >/dev/null; then | |
echo "Watching swift file $1" | |
while true; do fswatch --one-event $1 >/dev/null && echo "----------------"; echo `date +"%m-%d-%y %I:%M%p"`; echo "----------------" && swift $1; sleep 0.1; done | |
else | |
echo "You might need to run: brew install fswatch" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment