forked from npkgz/gulp-prettyerror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulp-prettyerror.js
executable file
·35 lines (27 loc) · 1.16 KB
/
gulp-prettyerror.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
var _gutil = require('gulp-util');
var _gplumber = require('gulp-plumber');
var PrettyError = (function(customErrorFormat){
// custom error format function provided ?
if (typeof customErrorFormat != 'undefined'){
// proxy
return _gplumber(function(error){
customErrorFormat.apply(this, [error, _gutil]);
});
}else{
// default appearance
return _gplumber(function(error){
_gutil.log('|- ' + _gutil.colors.bgRed.bold('Build Error in ' + error.plugin));
_gutil.log('|- ' + _gutil.colors.bgRed.bold(error.message));
// make sure there is codeFrame in the error object.
// gulp-less does not have it, so it will throw an error
if(error.codeFrame != 'undefined') {
// add indentation
var msg = error.codeFrame.replace(/\n/g, '\n ');
_gutil.log('|- ' + _gutil.colors.bgRed('>>>'));
_gutil.log('|\n ' + msg + '\n |');
_gutil.log('|- ' + _gutil.colors.bgRed('<<<'));
}
});
}
});
module.exports = PrettyError;