From 93d2a56f2359b62c5f71b4303d0bc839440bee91 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Tue, 1 Jun 2010 21:34:56 -0400 Subject: [PATCH] better fix for parse-error reporting --- lib/less/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/less/index.js b/lib/less/index.js index 5f990f15..84086ec2 100644 --- a/lib/less/index.js +++ b/lib/less/index.js @@ -38,11 +38,17 @@ var less = { var extract = ctx.extract; var error = []; - extract[0] && error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey')); + if (typeof(extract[0]) === 'string') { + error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey')); + } + error.push(ctx.line + ' ' + stylize(extract[1].slice(0, ctx.column), 'green') + stylize(stylize(extract[1][ctx.column], 'inverse') + extract[1].slice(ctx.column + 1), 'yellow')); - extract[2] && error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey')); + + if (typeof(extract[2]) === 'string') { + error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey')); + } error = error.join('\n') + '\033[0m\n'; require('sys').puts(stylize(ctx.message, 'red'), error);