add hook for import error

This commit is contained in:
Alexis Sellier
2012-02-01 19:55:15 +01:00
parent 557177c76d
commit 8e186400e0
2 changed files with 13 additions and 3 deletions

View File

@@ -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,
@@ -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" });
}
}
}

View File

@@ -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);
};
}