6

I am using the following line to watch a directory and run a script on changes:

watchman -- trigger my_directory runTransitionChecker '*' -- ruby ./my_script.rb

Everything works as I expect except all of the output of ruby ./my_script is directed to my

/usr/local/Cellar/watchman390/3.9.0/var/run/watchman/blahblah-state/log file.

From the docs and --help it seemed like maybe I was supposed to use the -f flag, but that doesn't seem to do it.

shaheenery
  • 8,457
  • 2
  • 17
  • 14

1 Answers1

1

I'd recommend that you do this to get a much more current version of watchman:

brew update
brew install watchman

Then you can use https://facebook.github.io/watchman/docs/watchman-make

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Wez Furlong
  • 4,727
  • 1
  • 29
  • 34
  • 1
    This does not answer the question. What flag is needed to direct the output to the console instead of the log file? is it --logfile (-o) if yes what is the path to the console is it "/dev/stdout"? – Arye Eidelman May 11 '20 at 02:29
  • 1
    while you can redirect the server logs to stdout using `--logfile=/dev/stdout`, and that does happen to include the output from all triggers among everything else that the server outputs, the best way to spawn a command when files change and see the output is using `watchman-make`. – Wez Furlong May 12 '20 at 06:38
  • Thanks, got it working. I had to jump through a bunch of hoops to install all the required software (pip, pywatchman and more). And install the latest watchman from source. – Arye Eidelman May 12 '20 at 17:41
  • 2
    The script I used was `watchman-make -p 'app/**' 'config/**' --run "rails test"`. (With a few more folders in addition to app and config.) – Arye Eidelman May 12 '20 at 17:48
  • You should add yours as an answer @AryeEidelman – Fred Guth Jan 26 '22 at 14:30