mirror of
https://github.com/less/less.js.git
synced 2026-02-05 20:44:58 -05:00
fix 'File not found' import error
This commit is contained in:
@@ -114,8 +114,7 @@ less.Parser.importer = function (file, paths, callback) {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
sys.error("file '" + file + "' wasn't found.\n");
|
||||
process.exit(1);
|
||||
callback({ type: 'File', message: "'" + file + "' wasn't found.\n" });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ less.Parser = function Parser(env) {
|
||||
n >= 0 && input.charAt(n) !== '\n';
|
||||
n--) { column++ }
|
||||
|
||||
return { line: index ? (input.slice(0, index).match(/\n/g) || "").length : null,
|
||||
return { line: typeof(index) === 'number' ? (input.slice(0, index).match(/\n/g) || "").length : null,
|
||||
column: column };
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ less.Parser = function Parser(env) {
|
||||
var line, lines, column;
|
||||
|
||||
return function (options, variables) {
|
||||
var frames = [];
|
||||
var frames = [], importError;
|
||||
|
||||
options = options || {};
|
||||
//
|
||||
@@ -368,7 +368,10 @@ less.Parser = function Parser(env) {
|
||||
throw new(LessError)(e, env);
|
||||
}
|
||||
|
||||
if (parser.imports.error) { throw parser.imports.error }
|
||||
if ((importError = parser.imports.error)) { // Check if there was an error during importing
|
||||
if (importError instanceof LessError) throw importError;
|
||||
else throw new(LessError)(importError, env);
|
||||
}
|
||||
|
||||
if (options.yuicompress && less.mode === 'node') {
|
||||
return require('./cssmin').compressor.cssmin(css);
|
||||
@@ -1017,12 +1020,12 @@ less.Parser = function Parser(env) {
|
||||
// stored in `import`, which we pass to the Import constructor.
|
||||
//
|
||||
"import": function () {
|
||||
var path, features;
|
||||
var path, features, index = i;
|
||||
if ($(/^@import\s+/) &&
|
||||
(path = $(this.entities.quoted) || $(this.entities.url))) {
|
||||
features = $(this.mediaFeatures);
|
||||
if ($(';')) {
|
||||
return new(tree.Import)(path, imports, features);
|
||||
return new(tree.Import)(path, imports, features, index);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
// `import,push`, we also pass it a callback, which it'll call once
|
||||
// the file has been fetched, and parsed.
|
||||
//
|
||||
tree.Import = function (path, imports, features) {
|
||||
tree.Import = function (path, imports, features, index) {
|
||||
var that = this;
|
||||
|
||||
this.index = index;
|
||||
this._path = path;
|
||||
this.features = features && new(tree.Value)(features);
|
||||
|
||||
@@ -29,7 +30,8 @@ tree.Import = function (path, imports, features) {
|
||||
// Only pre-compile .less files
|
||||
if (! this.css) {
|
||||
imports.push(this.path, function (e, root) {
|
||||
that.root = root;
|
||||
if (e) { e.index = index }
|
||||
that.root = root || new(tree.Ruleset)([], []);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user