mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
refactoring - add a env type to better organise its properties
This commit is contained in:
@@ -103,10 +103,11 @@ less.Parser.importer = function (file, paths, callback, env) {
|
||||
var pathname, dirname, data;
|
||||
|
||||
function parseFile(e, data) {
|
||||
if (e) return callback(e);
|
||||
if (e) { return callback(e); }
|
||||
|
||||
env = new less.tree.parseEnv(env);
|
||||
|
||||
var rootpath = env.rootpath,
|
||||
j = file.lastIndexOf('/');
|
||||
var j = file.lastIndexOf('/');
|
||||
|
||||
// Pass on an updated rootpath if path of imported file is relative and file
|
||||
// is in a (sub|sup) directory
|
||||
@@ -117,20 +118,13 @@ less.Parser.importer = function (file, paths, callback, env) {
|
||||
// - If path of imported file is '../mixins.less' and rootpath is 'less/',
|
||||
// then rootpath should become 'less/../'
|
||||
if(env.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
|
||||
rootpath = rootpath + file.slice(0, j+1); // append (sub|sup) directory path of imported file
|
||||
env.rootpath = env.rootpath + file.slice(0, j+1); // append (sub|sup) directory path of imported file
|
||||
}
|
||||
|
||||
env.contents[pathname] = data; // Updating top importing parser content cache.
|
||||
new(less.Parser)({
|
||||
paths: [dirname].concat(paths),
|
||||
filename: pathname,
|
||||
contents: env.contents,
|
||||
files: env.files,
|
||||
syncImport: env.syncImport,
|
||||
relativeUrls: env.relativeUrls,
|
||||
rootpath: rootpath,
|
||||
dumpLineNumbers: env.dumpLineNumbers
|
||||
}).parse(data, function (e, root) {
|
||||
env.paths = [dirname].concat(paths);
|
||||
env.filename = pathname;
|
||||
new(less.Parser)(env).parse(data, function (e, root) {
|
||||
callback(e, root, pathname);
|
||||
});
|
||||
};
|
||||
@@ -213,6 +207,7 @@ less.Parser.importer = function (file, paths, callback, env) {
|
||||
}
|
||||
}
|
||||
|
||||
require('./env');
|
||||
require('./functions');
|
||||
require('./colors');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user