Javascript 使用Gulp Notify&;的全局错误消息;水暖工
是否可以创建一个全局OnError函数,我可以将标题和错误消息传递给它 我希望在与管道工一起运行的所有任务中执行类似的操作:Javascript 使用Gulp Notify&;的全局错误消息;水暖工,javascript,error-handling,build-process,gulp,Javascript,Error Handling,Build Process,Gulp,是否可以创建一个全局OnError函数,我可以将标题和错误消息传递给它 我希望在与管道工一起运行的所有任务中执行类似的操作: onError = function(error) { $.notify.onError({ title: 'Error', subtitle: '<%= file.relative %> did not compile!', message: '<%= error.message %&
onError = function(error) {
$.notify.onError({
title: 'Error',
subtitle: '<%= file.relative %> did not compile!',
message: '<%= error.message %>'
})(error);
};
onError=函数(错误){
$.notify.onError({
标题:“错误”,
副标题:“未编译!”,
消息:“”
})(错误);
};
您只需将onError函数保存为变量即可:
var onError = notify.onError({
title: 'Error',
subtitle: '<%= file.relative %> did not compile!',
message: '<%= error.message %>'
});
在其他地方:
gulp.src('./src/*.scss')
.pipe(plumber({ errorHandler: onError }))
.pipe(sass())
.pipe(uglify())
.pipe(plumber.stop())
.pipe(gulp.dest('./dist'));
看见
gulp.src('./src/*.scss')
.pipe(plumber({ errorHandler: onError }))
.pipe(sass())
.pipe(uglify())
.pipe(plumber.stop())
.pipe(gulp.dest('./dist'));