Skip to content

Commit

Permalink
add hook for import error
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Feb 1, 2012
1 parent 557177c commit 8e18640
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/less/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var less = {
require('./tree/' + n);
});

less.Parser.importer = function (file, paths, callback) {
less.Parser.importer = function (file, paths, callback, env) {
var pathname;

// TODO: Undo this at some point,
Expand Down Expand Up @@ -116,7 +116,11 @@ less.Parser.importer = function (file, paths, callback) {
});
});
} else {
callback({ type: 'File', message: "'" + file + "' wasn't found.\n" });
if (typeof(env.errback) === "function") {
env.errback(file, paths, callback);
} else {
callback({ type: 'File', message: "'" + file + "' wasn't found.\n" });
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion lib/less/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,13 @@ if (less.mode === 'browser' || less.mode === 'rhino') {
// We pass `true` as 3rd argument, to force the reload of the import.
// This is so we can get the syntax tree as opposed to just the CSS output,
// as we need this to evaluate the current stylesheet.
loadStyleSheet({ href: path, title: path, type: env.mime }, callback, true);
loadStyleSheet({ href: path, title: path, type: env.mime }, function (e) {
if (e && typeof(env.errback) === "function") {
env.errback.call(null, path, paths, callback, env);
} else {
callback.apply(null, arguments);
}
}, true);
};
}

0 comments on commit 8e18640

Please sign in to comment.