gazer
v1.0.0
Published
Watch some files, do a thing
Downloads
57
Readme
Gazer
Watch some files, do a thing
A simple wrapper for Shama's gaze module that performs an arbitrary command when files change. Like watchify, but for everything.
Installation
This works best as a devDependency
in the project you plan to use it
in:
$ npm install --save-dev gazer
You can easily invoke gazer
with npm run
via npm scripts that you
set up in your package.json. See the usage example below for more
details.
If you want to use this everywhere, across multipe projects, you can install it globally, too:
$ npm install -g gazer
Usage
$ gazer --pattern "readme.md" echo "blorp"
[readme.md changes]
> "blorp"
Arbitrary watch tasks with npm run
If you haven't read substack's post describing lightweight build steps
with npm run
, I'll
give you a moment to get up to speed.
Here's how you might use gazer
to run a build task every time a file
changes:
{
"scripts": {
"build-less": "lessc public/less/main.less public/css/main.css",
"watch-less": "gazer -p 'public/less/**/*.less' npm run build-less"
}
}
And then start the watcher:
$ npm run watch-less
Double dash
If you need to pass a -p argument to the command you're running, use
--
to separate the option arguments from the positional arguments:
$ gazer -p readme.md -- echo -p