[Pkg-javascript-commits] [less.js] 197/285: make sure plugins can be loaded from the current directory if lessc is installed globally
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit 65702f80a331e315be940dc044315bc0767cc00b
Author: Luke Page <luke.a.page at gmail.com>
Date: Sun Oct 19 19:09:23 2014 +0100
make sure plugins can be loaded from the current directory if lessc is installed globally
---
lib/less-node/plugin-loader.js | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/lib/less-node/plugin-loader.js b/lib/less-node/plugin-loader.js
index 06c70a7..bef1d22 100644
--- a/lib/less-node/plugin-loader.js
+++ b/lib/less-node/plugin-loader.js
@@ -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++) {
--
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