From 5c1478922811d6da87519b276ab01ff537de0802 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Mon, 30 Mar 2015 08:16:04 -0400 Subject: [PATCH] Updated Message style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligns with Stylish reporter (used in ESLint, jshint-stylish, etc… Removed colors from message except for which is a standard Gulp log output color Includes line and column in error report --- index.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index ee7dc15..fd9cf8a 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ var gulpSass = function gulpSass(options, sync) { return through.obj(function(file, enc, cb) { var opts, filePush, + errorM, callback, result; @@ -53,15 +54,29 @@ var gulpSass = function gulpSass(options, sync) { cb(null, file); }; + ////////////////////////////// + // Handles error message + ////////////////////////////// + errorM = function errorM(error) { + var relativePath = path.relative(process.cwd(), error.file), + message = ''; + + message += gutil.colors.underline(relativePath) + '\n'; + message += gutil.colors.gray(' ' + error.line + ':' + error.column) + ' '; + message += error.message; + + return cb(new gutil.PluginError( + PLUGIN_NAME, message + )); + }; + if (sync !== true) { ////////////////////////////// // Async Sass render ////////////////////////////// callback = function(error, obj) { if (error) { - return cb(new gutil.PluginError( - PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) - )); + return errorM(error); } filePush(obj); }; @@ -78,9 +93,7 @@ var gulpSass = function gulpSass(options, sync) { filePush(result); } catch(error) { - return cb(new gutil.PluginError( - PLUGIN_NAME, error.message + ' ' + gutil.colors.cyan('line ' + error.line) + ' in ' + gutil.colors.magenta(error.file) - )); + return errorM(error); } } });