UNPKG

591 Btext/coffeescriptView Raw
1hound = require 'hound'
2colors = require 'colors'
3{sep} = require 'path'
4
5module.exports.watcher = (opts) ->
6
7 return unless opts.path? and opts.handler?
8 watchdir = process.cwd() + sep + opts.path
9
10 try
11 emitter = hound.watch watchdir
12 emitter.on 'change', opts.handler.change
13 console.log 'ipso:' + " watching directory: .#{sep}#{opts.path}".grey
14
15 catch error
16 if error.errno == 34
17 console.log 'ipso:' + " expected directory: .#{sep}#{opts.path}".red
18 else
19 console.log 'ipso:' + " exception #{error}".red
20