Skip to content

Commit

Permalink
This commit provides a hacky fix to make --include-paths work with Rh…
Browse files Browse the repository at this point in the history
…ino.
  • Loading branch information
gdelhumeau committed May 13, 2014
1 parent 084e733 commit f91f360
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/less/rhino.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,24 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
try {
data = readFile(href);
} catch (e) {
callback({ type: 'File', message: "'" + less.modules.path.basename(href) + "' wasn't found" });
// try with another path (see --include-paths)
var currentPathIndex = -1;
for (var i=0; i<env.paths.length; ++i) {
var path = env.paths[i];
if (currentFileInfo.currentDirectory == path) {
currentPathIndex = i;
break;
}
}
if (currentPathIndex >= 0 && currentPathIndex < env.paths.length - 1) {
// hack
currentFileInfo.currentDirectory = env.paths[currentPathIndex+1];
// try again!
less.Parser.fileLoader(file, currentFileInfo, callback, env);
} else {
// we have tried all the paths without success :(
callback({ type: 'File', message: "'" + less.modules.path.basename(href) + "' wasn't found" });
}
return;
}

Expand Down Expand Up @@ -261,7 +278,7 @@ function writeFile(filename, content) {
break;
case 'include-path':
if (checkArgFunc(arg, match[2])) {
options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
options.paths = match[2].split(java.io.File.pathSeparator)
.map(function(p) {
if (p) {
// return path.resolve(process.cwd(), p);
Expand Down

0 comments on commit f91f360

Please sign in to comment.