mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
make sure plugins can be loaded from the current directory if lessc is installed globally
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
var path = require("path");
|
||||
/**
|
||||
* Node Plugin Loader
|
||||
*/
|
||||
@@ -47,6 +48,25 @@ PluginLoader.prototype.versionToString = function(version) {
|
||||
return versionString;
|
||||
};
|
||||
PluginLoader.prototype.tryRequirePlugin = function(name) {
|
||||
// is at the same level as the less.js module
|
||||
try {
|
||||
return require("../../../" + name);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// is installed as a sub dependency of the current folder
|
||||
try {
|
||||
return require(path.join(process.cwd(), "node_modules", name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// is referenced relative to the current directory
|
||||
try {
|
||||
return require(path.join(process.cwd(), name));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
// unlikely - would have to be a dependency of where this code was running (less.js)...
|
||||
if (name[0] !== '.') {
|
||||
try {
|
||||
return require(name);
|
||||
@@ -54,11 +74,6 @@ PluginLoader.prototype.tryRequirePlugin = function(name) {
|
||||
catch(e) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
return require("../../../" + name);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
};
|
||||
PluginLoader.prototype.printUsage = function(plugins) {
|
||||
for(var i = 0; i < plugins.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user