Watchman

Watchman watches files and runs things when they change. It consists of watches and triggers. Watches are folders to watch for changes in, and triggers are things to do when changes happen.

Watches

You can watch a folder with watchman watch ~/my/project, and stop watching it with watchman watch-del ~/my/project.

When you delete a watch, it also will delete any triggers associated with the watch.

Triggers

Triggers contain a watch, a name, some patterns to match against filenames, and a command to run.

watchman -- trigger ~/foo css '*.scss' '*.sass' -- npm buildcss

This creates a trigger named css for the watch ~/foo. It will look for files matching the pattern *.scss or *.sass, and run npm buildcss plus the filename when they change.

If the file ~/foo/foobar.scss changed, then watchman would run the command npm buildcss foobar.scss.