Last active
April 20, 2016 09:23
-
-
Save nahuelsotelo/758849ffbdb553cb49c1 to your computer and use it in GitHub Desktop.
ERROR HANDLER
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var beep = require('beepbeep'); | |
var colors = require('colors'); | |
var onError = function(err) { | |
beep([200, 200]); | |
var formatOutput = function(context) { | |
var msg, file, line, description; | |
if(context == 'gulp-babel') { | |
file = String(err.fileName); | |
line = String(err.loc.line); | |
description = String(err.name + err.message.replace(err.fileName, '')); | |
} else if(err.plugin == 'gulp-sass') { | |
file = String(err.relativePath); | |
line = String(err.line); | |
description = String(err.messageOriginal); | |
} else { | |
file = ''; | |
line = ''; | |
description = err; | |
} | |
msg = | |
'file: '.bold.white + file.bold.green + '\n' + | |
'line: '.bold.white + line.bold.green + '\n\n' + | |
description.bold.red + '\n'; | |
return msg | |
} | |
var errorMsg = formatOutput(err.plugin); | |
console.log( | |
'\n\n******************************************\n'.bold.gray + | |
' ***********'.bold.gray + | |
' \(╯°□°)╯'.bold.magenta + ' ︵ '.bold.blue + 'ɹoɹɹǝ '.bold.red + | |
'***********'.bold.gray + | |
'\n******************************************\n\n'.bold.gray + | |
errorMsg + | |
'\n******************************************\n\n'.bold.gray); | |
this.emit('end'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment