Skip to content

Commit dca9643

Browse files
committed
If the callback throws an error and imports are syncronous, let the error fall through to the calling scope.
1 parent 420acff commit dca9643

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/less/import-visitor.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
tree.importVisitor.prototype = {
1111
isReplacing: true,
1212
run: function (root) {
13-
// process the contents
14-
this._visitor.visit(root);
13+
var error;
14+
try {
15+
// process the contents
16+
this._visitor.visit(root);
17+
}
18+
catch(e) {
19+
error = e;
20+
}
1521

1622
this.isFinished = true;
1723

1824
if (this.importCount === 0) {
19-
this._finish();
25+
this._finish(error);
2026
}
2127
},
2228
visitImport: function (importNode, visitArgs) {
@@ -43,11 +49,11 @@
4349
if (e && !e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; }
4450
if (imported && !importNode.options.multiple) { importNode.skip = imported; }
4551

46-
var subFinish = function() {
52+
var subFinish = function(e) {
4753
importVisitor.importCount--;
4854

4955
if (importVisitor.importCount === 0 && importVisitor.isFinished) {
50-
importVisitor._finish();
56+
importVisitor._finish(e);
5157
}
5258
};
5359

lib/less/parser.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,8 @@ less.Parser = function Parser(env) {
477477
};
478478

479479
if (env.processImports !== false) {
480-
try {
481-
new tree.importVisitor(this.imports, finish)
482-
.run(root);
483-
}
484-
catch(e) {
485-
error = e;
486-
}
480+
new tree.importVisitor(this.imports, finish)
481+
.run(root);
487482
} else {
488483
finish();
489484
}

0 commit comments

Comments
 (0)