node.js - gulp中有没有办法监听task执行成功或者失败的状态
PHPz
PHPz 2017-04-17 11:52:00
0
1
695

代码如下:
gulp.task('copyfonts',function(){
return gulp.src(staticConfig['fonts'] + '/')
.pipe(gulp.dest('./dist/fonts/'));
})

然后我想监控 copyfonts 任务是否成功
gulp.task('aaa', ['copyfonts'],function(err){
console.log(err)
});

此时没有输出

假如改成一个不存在地址:
gulp.task('copyfonts',function(){
return gulp.src(staticConfig['foxxxnts'] + '/')
.pipe(gulp.dest('./dist/fonts/'));
})

还是没有输出!

问题是如何监控copyfonts 是否成功执行??

PHPz
PHPz

学习是最好的投资!

reply all(1)
Ty80

gulp’s task system is based on orchestrator. Several events are provided: start, stop, err, task_start, task_stop, task_err, task_not_found, task_recursion.
You can monitor it as follows

javascriptvar gulp = require('gulp');

gulp.task('default',function(){
    return gulp.src('./**/*.*')
    .pipe()
}).on('task_start',function(){
    console.log('start');
}).on('task_err',function(err){
    console.log('error');
}).on('task_stop',function(){
    console.log('stop');
});

There is also a ready-made plug-in gulp-plumber to monitor task exceptions.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!