wr

watch files and run a command when they change

wr -- watch files and run a command when they change

wr [-cvV] command [file ...]

wr will watch the set of files and directories specified on the command line, and run the specified command when any of the files changes. For each file operand which is a directory, all the files in the directory (recursively) will be watched.

If no files are specified, it's as if you passed "." as the file parameter.

The following options are available:

-c minutes --chime=minutes

Write a diagnostic message after minutes have elapsed since last running a command, to remind you wr is running.

-v --verbose

Generate additional diagnostic information.

-V

Display the version number and exit.

-?, -h

Display help.

The following is how to run make when any file in the current directory changes:

    wr make

More likely you can whittle the list of source files checked a bit. The following will run make any file in the src, doc or test directories changes:

    wr make src doc test

To run a command with arguments, quote the command you want to run. The following will run the command "echo a file changed" when any file in the current directory changes:

    wr "echo a file changed"

wr will not normally exit. Use ctrl-c or equivalent to kill the process from the command-line.

If the current directory has a .wr file in it, that file is assumed to have the contents of a wr invocation in it, one argument per line. The file may contain blank lines or lines starting with the # character, which are considered comments.

The stdout and stderr from the command being run are passed directory to wr's stdout and stderr. stdin for the command will not be available for the command.

Diagnostic information from wr will be written to stderr.

wr is a port of Patrick Mueller's run-when-changed.py script to node.

  • 2012-01-09: version 1.0.0