我正在使用 gulp-plumber + gulp-notify 并希望将任务名称作为标题放入 gulp-notify 中。 以下是我编写的代码,提前致谢。
gulp.task('SOMETASK', function() {
return gulp.src(sourcePaths)
.pipe(plumber({errorHandler: notify.onError({
message: "<%= error.message %>",
title: "I WANT TO PUT TASK NAME HERE"
})}))
// omitted below
});
最佳答案
gulp.Gulp.prototype.__runTask = gulp.Gulp.prototype._runTask;
gulp.Gulp.prototype._runTask = function(task) {
this.currentTask = task;
this.__runTask(task);
}
gulp.task("someTask", function(){
console.log( this.currentTask.name );
}
关于javascript - 如何在gulp中获取任务内部的任务名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27161903/