UNPKG

402 Btext/coffeescriptView Raw
1Content = require './content'
2
3WATCH_OPTS =
4 persistent: false
5 interval: 1
6
7fs = require 'fs'
8
9watching = {}
10exports.onChange = ( key, path, cb ) ->
11 if typeof path is 'function'
12 cb = path
13 path = key
14 unless watching[key]?
15 Logger.debug "Watching #{key}..."
16 watching[key] = true
17 fs.watchFile path, WATCH_OPTS, ( newStat, oldStat ) ->
18 cb() if oldStat.mtime < newStat.mtime