我尝试使用以下代码拦截compass watch
输出:
var spawn = require('child_process').spawn;
var child = spawn('compass', ['watch'], { cwd: process.cwd() });
process.on('data', function (data) {
console.log('[log] ' + data);
});
我的问题是:我必须保存文件两次才能在stdout中出现覆盖消息。这是一个示例输出...
在node compass.js
之后
[log] >>> Compass is watching for changes. Press Ctrl-C to Stop.
我保存文件后
[log] >>> Change detected at 20:17:19 to: components/_avatar.scss
我第二次保存文件后
[log] overwrite assets/css/modules/projects.css
>>> Change detected at 20:17:26 to: components/_avatar.scss
它看起来像"覆盖assets / css / modules / projects.css"正在缓冲。有什么办法可以避免这种缓冲吗?
答案 0 :(得分:0)
正如我刚刚发现的那样,罗盘(或OSX)是真正的罪魁祸首。如果我运行compass watch
,输出会立即更新。但是,如果我运行compass watch > out.log
,则会出现与节点相同的行为。