全球错误消息使用Gulp Notify&水管工人 [英] Global error message using Gulp Notify & Plumber
本文介绍了全球错误消息使用Gulp Notify&水管工人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以创建一个全局OnError函数,我可以传递一个标题和错误消息?
Is it possible to create a global OnError function that I can pass a title and the error message to?
我正在寻找所有这样做任务与水管工运行:
I'm looking to do something like this for all tasks ran with plumber:
onError = function(error) {
$.notify.onError({
title: 'Error',
subtitle: '<%= file.relative %> did not compile!',
message: '<%= error.message %>'
})(error);
};
推荐答案
您可以将onError函数简单地保存为变量:
You can simply save the onError function as a variable:
var onError = notify.onError({
title: 'Error',
subtitle: '<%= file.relative %> did not compile!',
message: '<%= error.message %>'
});
在几个不同的gulp任务和水喉匠功能:
And in several different gulp-tasks and plumber-functions:
gulp.src('./src/*.ext')
.pipe(plumber({ errorHandler: onError }))
.pipe(coffee())
.pipe(gulp.dest('./dist'));
和其他地方:
gulp.src('./src/*.scss')
.pipe(plumber({ errorHandler: onError }))
.pipe(sass())
.pipe(uglify())
.pipe(plumber.stop())
.pipe(gulp.dest('./dist'));
这篇关于全球错误消息使用Gulp Notify&水管工人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文