【发布时间】:2012-05-15 03:49:38
【问题描述】:
Ubuntu 12.04Node v0.6.14CoffeeScript 1.3.1
fs.watchFile coffee_eval, (e) ->
console.log e
result = spawn 'coffee', ['-bc', coffee_eval]
msg = ''
result.stderr.on 'data', (str) ->
msg+= str
result.stderr.on 'end', ->
console.log 'msg: ', msg
print "!! #{coffee_eval}\n"
要点上的完整代码:https://gist.github.com/2621576
每次我保存观看的文件时,主函数都会调用 twitce 而不是一次。
我的编辑器是 Sumlime Text 2。
输出的话可以看:
【问题讨论】:
-
我在 Windows 上使用 fs.watch 时遇到了同样的问题。有趣的是,使用 fs.watchFile(他们在文档中建议反对)效果很好。
标签: node.js