gulp-notify处理报错----gulp系列(二)
上一节,以less为例,入门了gulp,并为任务结构做了抽离。
前端们,gulp该用起来了,简单的demo入门——gulp系列(一)
本节学习下gulp-notify,官方这样解释的:
gulp-notify :
gulp plugin to send messages based on Vinyl Files or Errors to Mac OS X, Linux or Windows using the node-notifier module. Fallbacks to Growl or simply logging
目的:
我们用notify的功能主要有两点,显示报错信息和报错后不终止当前gulp任务。
拿系列(一)来说,less如果出现编译错误,就会报错然后终止任务,这时less修改正确后,你还得手动重启gulp任务。
开始:
现在,我们在系列(一)的基础上,新建(检出)一个分支,添加notify功能
1.安装gulp-notify: npm install --save-dev gulp-notify
2.在gulp文件夹里新建一个目录,名叫util,目录里新建文件handleErrors.js用来配置notify
handleError.js代码如下:
var notify = require("gulp-notify");module.exports = function(){var args = Array.prototype.slice.call(arguments);notify.onError({title: 'compile error',message: '<%=error.message %>'}).apply(this, args);//替换为当前对象this.emit();//提交 }
3.在less中引用,现在将less.js修改为如下:
var gulp = require('gulp'); var less = require('gulp-less'); var config = require('../config').less; var handleErrors = require('../util/handleErrors');gulp.task('less', function(){return gulp.src(config.src) //less源文件.pipe(less(config.settings)) //执行编译.on('error', handleErrors) //交给notify处理错误.pipe(gulp.dest(config.dest)) //输出目录 });
最终:
如果出现less错误,便会输出错误信息并继续gulp任务
还是那句话多看官方文档。
>>> github 地址,请选择 notify 分支<<<
转载于:https://www.cnblogs.com/1wen/p/4552485.html
gulp-notify处理报错----gulp系列(二)相关推荐
- Debezium报错处理系列之二十九:Make sure that an instance of SQL Server is running on the host and accepting TCP
Debezium报错处理系列之二十九:Make sure that an instance of SQL Server is running on the host and accepting TCP ...
- Debezium报错处理系列之三十六:Task threw an uncaught and unrecoverable exception. Task is being killed and will
Debezium报错处理系列之三十六:Task threw an uncaught and unrecoverable exception. Task is being killed and will ...
- Debezium报错处理系列九:“ddl“ : “# Dummy event replacing event type 160 that slave cannot handle.“
Debezium报错处理系列九:"ddl" : "# Dummy event replacing event type 160 that slave cannot han ...
- Debezium报错处理系列十一:Data row is smaller than a column index, internal schema representation is probabl
Debezium报错处理系列十一:Data row is smaller than a column index, internal schema representation is probably ...
- Debezium报错处理系列之三十三:Unexpected error while connecting to MySQL and looking at BINLOG_FORMAT
Debezium报错处理系列之三十三:Unexpected error while connecting to MySQL and looking at BINLOG_FORMAT mode: Cau ...
- Debezium报错处理系列之三十八:Timeout expired while fetching topic metadata
Debezium报错处理系列之三十八:'trace': 'org.apache.kafka.common.errors.TimeoutException: Timeout expired while ...
- pycharm安装pytorch报错 提示系列问题 torch 包找不到因为pip版本低,结果升级了pip从19.3到20.2 4又提示高版不支持torch安装
pycharm安装pytorch报错 提示系列问题 torch 包找不到因为pip版本低,结果升级了pip从19.3到20.2 4又提示高版不支持torch安装 DEPRECATION: The - ...
- 报错锦集二“nginx: [emerg] unknown directive “set_real_ip_from“ in /usr/local/nginx/conf/nginx.conf:50 ngi
报错锦集二"nginx: [emerg] unknown directive "set_real_ip_from" in /usr/local/nginx/conf/ng ...
- gulp启动项目报错
有一个需要gulp启动的项目,在启动过程中出现错误,用来记录一下. 直接到包含gulpfile.js的项目目录下用gulp启动报错,查看node版本是14.15.3版本,gulp是3.9.1版本,可能 ...
最新文章
- 做 Java 工程师,挺!好!
- 一 如何检查oracle的归档日志及空间占用率,清除归档日志、Oracle归档日志使用情况查询、查看oracle数据库一周产生的归档日志
- Native C++ _isnan()函数的应用
- jvm Classload method介绍
- OpenCV中图像轮廓检测
- js获取后端传过来的数据
- 深度:企业为什么需要一个平台级的OA产品?
- 考研计算机320分什么水平,考研320分算什么水平,能上211、985吗?很多人都答不上...
- nan null underfined的区别
- 车载网络基础——预备篇
- R语言第十讲 逻辑斯蒂回归
- 远端WWW服务支持TRACE请求
- 让子盒子水平和垂直居中的五种方法
- 湖北智禾教育:淘宝店铺详情页提高转化率该怎么做
- 方程sin平方x-x平方+1=0的有根区间?
- ASM 无法发现候选磁盘组----grid 11.2.0.3 asm 自检通不过 prvf-5184
- 推荐一些类似《纪念碑谷》这样接近艺术的游戏
- 伤寒杂病论.辨少阴病脉证并治
- 用上帝的恋爱公式讲线性回归-上
- 『2月特刊』伟大的朋友丨拿破仑(3)
热门文章
- 解决w3wp.exe内存占用问题[转载]
- 清华大学出品:罚梯度范数提高深度学习模型泛化性
- SimVLM:拒绝各种花里胡哨!CMUGoogle提出弱监督极简VLP模型,在多个多模态任务上性能SOTA...
- 开源库 | 监控视频中的目标检测与跟踪
- 数据太少怎么办?试试自监督学习,CV训练新利器,fast.ai新教程,LeCun点评
- 6 篇 2019 年最新模型剪枝技术合集
- FaceBoxes—官方开源CPU实时高精度人脸检测器
- 轻量化版本优于MobileNet系列 | Tokens-to-Token ViT: Training Vision Transformers from Scratch on ImageNet
- TCP、UDP(网络协议:传输层协议)
- 什么是嵌入式视觉、行业应用、目前挑战