var jasmine = require('gulp-jasmine');
var debug = require('gulp-debug');
var testFunc = function(platform, testType) {
var timer = startTimer();
console.log('started!');
return gulp.src('./src/**/_test/**/*.mem.js')
.pipe(jasmine({
verbose: !!args.verbose,
timeout: 15000
}))
.pipe(debug())
.on('error', function(e) {
console.log('started!');
throw e;
})
.on('end', function() {
console.log('end!');
console.log(stopTimer(timer));
});
};
gulp.task('mem', function(done) {
testFunc('chrome', 'mem').on('end', function() {
console.log('done!');
done();
});
});
On gulp v3.9.1。上面的代碼完成後沒有記錄「結束!」或「完成!」到控制檯。我該怎麼做才能做到這一點?吞吐任務在Stream發出「結束」事件之前退出
My console output:
> gulp mem
[13:10:39] Using gulpfile ~/foo/bar/gulpfile.js
[13:10:39] Starting 'mem'...
started!
[13:10:39] gulp-debug: src/components/avatar/_test/avatar.mem.js
[13:10:39] gulp-debug: src/factories/store/_test/store.mem.js
[13:10:39] gulp-debug: 2 items
UPDATE:
注意到下面遲緩芽孢桿菌的建議,這對於同步任務運作良好,像一飲而盡調試。但是異步的,比如吞噬茉莉花,流在任務完成之前結束。您還會注意到,「完成‘MEM’X秒後」不打印:
My console output:
> gulp mem
[13:10:39] Using gulpfile ~/foo/bar/gulpfile.js
[13:10:39] Starting 'mem'...
started!
ended!
...
3 specs, 0 failures
Finished in 18.5 seconds
在對數據做任何事情之前設置事件。你嘗試過嗎? – KreemPuff
嗯,這樣的工作......我很好奇,爲什麼我看到的每個例子吞噬事件處理程序添加在管道列表的最後,而不是開始? – AlexZ
它們可能是更長時間運行任務的示例。但通常情況下,您希望儘可能早地設置偵聽器 – KreemPuff