[Pkg-javascript-commits] [less.js] 13/58: test for absolute paths and do not try and join if absolute. Fixes #2375
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:28:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.3.0
in repository less.js.
commit dff4540f5b21553abde97dbffcb537055bd43e1a
Author: Luke Page <luke.a.page at gmail.com>
Date: Sun Jan 11 16:31:32 2015 +0000
test for absolute paths and do not try and join if absolute. Fixes #2375
---
lib/less-node/file-manager.js | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/less-node/file-manager.js b/lib/less-node/file-manager.js
index 56f788d..3d1a185 100644
--- a/lib/less-node/file-manager.js
+++ b/lib/less-node/file-manager.js
@@ -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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list