Man*_*utz 76
我会选择:
var spawn = require('child_process').spawn;
var fancyLog = require('fancy-log');
var beeper = require('beeper');
gulp.task('default', function(){
gulp.watch('*.js', function(e) {
// Do run some gulp tasks here
// ...
// Finally execute your script below - here "ls -lA"
var child = spawn("ls", ["-lA"], {cwd: process.cwd()}),
stdout = '',
stderr = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function (data) {
stdout += data;
fancyLog(data);
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
stderr += data;
fancyLog.error(data));
beeper();
});
child.on('close', function(code) {
fancyLog("Done with exit code", code);
fancyLog("You access complete stdout and stderr from here"); // stdout, stderr
});
});
});
Run Code Online (Sandbox Code Playgroud)
这里没有什么真正的"吞吐" - 主要是使用子进程http://nodejs.org/api/child_process.html并将结果欺骗成花式日志
Eri*_*rik 44
使用https://www.npmjs.org/package/gulp-shell.
一个方便的gulp命令行界面
| 归档时间: |
|
| 查看次数: |
48673 次 |
| 最近记录: |