The StackOverflow question you've quoted has been added another answer - there's
fswatch utility right there in Homebrew.
fswatch command is more similar to
inotifiwait. Means, instead of one-shot waiting for file changes and then exiting, it enters an infinite loop printing the changed files - so you can catch the changes with an Unix pipe. Then your script would be "inside out" let's say.
For instance, on Linux I usually have a oneliner which runs my command on file changes using
while true; do inotifywait -q -e modify files... ; my_command; done
fswatch to have same effect I need to:
fswatch files... | (while read; do my_command; done)
The above assumes you don't need changed files as arguments to your command. If it happens you need them, it'd look like this:
fswatch files... | (while read x; do echo $x | xargs my_command; done)
Hope this helps :)