1 |
|
2 | var colors, hound, sep;
|
3 |
|
4 | hound = require('hound');
|
5 |
|
6 | colors = require('colors');
|
7 |
|
8 | sep = require('path').sep;
|
9 |
|
10 | module.exports.watcher = function(opts) {
|
11 | var emitter, error, watchdir;
|
12 | if (!((opts.path != null) && (opts.handler != null))) {
|
13 | return;
|
14 | }
|
15 | watchdir = process.cwd() + sep + opts.path;
|
16 | try {
|
17 | emitter = hound.watch(watchdir);
|
18 | emitter.on('change', opts.handler.change);
|
19 | return console.log('ipso:' + (" watching directory: ." + sep + opts.path).grey);
|
20 | } catch (_error) {
|
21 | error = _error;
|
22 | if (error.errno === 34) {
|
23 | return console.log('ipso:' + (" expected directory: ." + sep + opts.path).red);
|
24 | } else {
|
25 | return console.log('ipso:' + (" exception " + error).red);
|
26 | }
|
27 | }
|
28 | };
|