From 63bfdbfe4b57b8f8dd0e5af12274313fb2b3457c Mon Sep 17 00:00:00 2001 From: cloudhead Date: Tue, 1 Jun 2010 21:28:42 -0400 Subject: [PATCH] fix parse error reporting when at beginning of file --- lib/less/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/less/index.js b/lib/less/index.js index 369c123e..5f990f15 100644 --- a/lib/less/index.js +++ b/lib/less/index.js @@ -36,12 +36,14 @@ var less = { }, writeError: function (ctx) { var extract = ctx.extract; - var error = [ - stylize((ctx.line - 1) + ' ' + extract[0], 'grey'), - ctx.line + ' ' + stylize(extract[1].slice(0, ctx.column), 'green') + - stylize(stylize(extract[1][ctx.column], 'inverse') + extract[1].slice(ctx.column + 1), 'yellow'), - stylize((ctx.line + 1) + ' ' + extract[2], 'grey') - ].join('\n') + '\033[0m\n'; + var error = []; + + extract[0] && 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')); + error = error.join('\n') + '\033[0m\n'; require('sys').puts(stylize(ctx.message, 'red'), error); }