Permalink
Browse files

Fix less error handling during ast.toCSS

Fixes #1877
  • Loading branch information...
1 parent 51148c8 commit c0447737ec725e316e5d1d543f797456b4db7524 @glasser glasser committed Mar 4, 2014
Showing with 9 additions and 10 deletions.
  1. +9 −10 packages/less/plugin/compile-less.js
@@ -25,10 +25,17 @@ Plugin.registerSourceHandler("less", function (compileStep) {
var parser = new less.Parser(options);
var astFuture = new Future;
- var ast;
+ var sourceMap = null;
try {
parser.parse(source, astFuture.resolver());
- ast = astFuture.wait();
+ var ast = astFuture.wait();
+
+ var css = ast.toCSS({
+ sourceMap: true,
+ writeSourceMap: function (sm) {
+ sourceMap = JSON.parse(sm);
+ }
+ });
} catch (e) {
// less.Parser.parse is supposed to report any errors via its
// callback. But sometimes, it throws them instead. This is
@@ -42,14 +49,6 @@ Plugin.registerSourceHandler("less", function (compileStep) {
return;
}
- var sourceMap = null;
- var css = ast.toCSS({
- sourceMap: true,
- writeSourceMap: function (sm) {
- sourceMap = JSON.parse(sm);
- }
- });
-
if (sourceMap) {
sourceMap.sources = [compileStep.inputPath];

0 comments on commit c044773

Please sign in to comment.