1 | Content = require './content'
|
2 |
|
3 | WATCH_OPTS =
|
4 | persistent: false
|
5 | interval: 1
|
6 |
|
7 | fs = require 'fs'
|
8 |
|
9 | watching = {}
|
10 | exports.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
|