expatr v1.0.0
expatr - react on file system events
It's a tiny utility which just listen to file system events(like add/update/remove) and run some command once the such event is triggered.
Installation
- Install the expatr utility via npm/yarn:
$ yarn global add expatr
# -or-
$ npm i -g expatr
Usage (example)
- Run the expatr in any empty directory:
$ expatr --filter=newfile.txt rm newfile.txt
- Trigger file system change in another terminal:
$ touch newfile.txt
- Make sure that the 'rm newfile.txt' command was executed:
$ cat newfile.txt
cat: can't open 'newfile.txt': No such file or directory
The 'expatr' supports the next options:
-t --timeout - when the timeout is reached, shutdown without the command execution
-p --poll - use operating system(nix/macos) facilities to be notified about file system events
-i --ignore - use simple pattern to ignore some paths
-f --filter - use regex to filter paths which could cause command execution
The rest arguments will be assumed as the command and its arguments. All stdin/stdout/stderr streams is piped from/to the child process. The child process exit code will be forwarded as an exit code of the 'expatr'.
License
MIT License - see the LICENSE for more details.
4 years ago