mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
test for absolute paths and do not try and join if absolute. Fixes #2375
This commit is contained in:
@@ -18,19 +18,23 @@ FileManager.prototype.supportsSync = function(filename, currentDirectory, option
|
||||
FileManager.prototype.loadFile = function(filename, currentDirectory, options, environment, callback) {
|
||||
var fullFilename,
|
||||
data,
|
||||
isAbsoluteFilename = this.isPathAbsolute(filename),
|
||||
filenamesTried = [];
|
||||
|
||||
options = options || {};
|
||||
|
||||
var paths = [currentDirectory];
|
||||
var paths = isAbsoluteFilename ? [""] : [currentDirectory];
|
||||
if (options.paths) paths.push.apply(paths, options.paths);
|
||||
if (paths.indexOf('.') === -1) paths.push('.');
|
||||
if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }
|
||||
|
||||
if (options.syncImport) {
|
||||
var err, result;
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
try {
|
||||
fullFilename = path.join(paths[i], filename);
|
||||
fullFilename = filename;
|
||||
if (paths[i]) {
|
||||
fullFilename = path.join(paths[i], fullFilename);
|
||||
}
|
||||
filenamesTried.push(fullFilename);
|
||||
fs.statSync(fullFilename);
|
||||
break;
|
||||
@@ -55,7 +59,10 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
|
||||
return new PromiseConstructor(function(fulfill, reject) {
|
||||
(function tryPathIndex(i) {
|
||||
if (i < paths.length) {
|
||||
fullFilename = path.join(paths[i], filename);
|
||||
fullFilename = filename;
|
||||
if (paths[i]) {
|
||||
fullFilename = path.join(paths[i], fullFilename);
|
||||
}
|
||||
fs.stat(fullFilename, function (err) {
|
||||
if (err) {
|
||||
filenamesTried.push(fullFilename);
|
||||
|
||||
Reference in New Issue
Block a user