forked from aqzhyi/gulp-plumber-notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (28 loc) · 946 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
var colors = require('colors');
var plumber = require('gulp-plumber');
var notifier = require('node-notifier');
var dateformat = require('dateformat');
module.exports = index['default'] = index.index = index; // eslint-disable-line dot-notation
/////
function index() {
return plumber({
errorHandler: errorHandler
});
}
function errorHandler(error) {
var lineNumber = (error.lineNumber) ? 'LINE ' + error.lineNumber + ' -- ' : '';
var time = '[' + colors.grey(dateformat(new Date(), 'HH:MM:ss')) + ']';
process.stdout.write(time + ' ');
var fullMessage =
'Error in plugins **' + error.plugin + '**:' + error.message;
notifier.notify({
title: 'Task Failed [' + error.plugin + ']',
line: lineNumber + 'See console.',
message: error.message,
});
fullMessage = colors.bgRed.white(fullMessage);
console.log(fullMessage);
// Prevent the 'watch' task from stopping
this.emit('end');
}