Watch files and trigger actions. Uses chokidar to watch the filesystem.
npm install --save-dev kolla
kolla
takes two arguments. The first one is a glob, file or dir. The second one is the command to be executed on file change. If you put a :
before the command it will execute the npm script with the same name.
package.json
"scripts": {
"lint": "eslint .",
"lint:watch": "kolla '**/*.js' :lint",
"test:elm": "elm-test test/TestRunner.elm",
"test:elm:watch": "kolla '**/*.elm' :test:elm",
"crazy": "kolla '**/*' 'echo hello!'"
}
watcher() takes the same two arguments as the CLI. Doesn't return anything so might not be useful.
import watcher from 'kolla';
watcher('**/*.js', ':lint')