[Pkg-javascript-commits] [less.js] 164/285: Fix plugin issues

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:50 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 c0f60cccf8f2309eb76c474781da683bf4278afb
Author: Luke Page <luke.a.page at gmail.com>
Date:   Thu Oct 9 18:21:31 2014 +0100

    Fix plugin issues
---
 bin/lessc                      |  4 ++--
 lib/less-node/plugin-loader.js | 15 ++++++++++++---
 lib/less/render.js             |  4 ++--
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/bin/lessc b/bin/lessc
index c87eac0..fe65b4f 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -227,7 +227,7 @@ args = args.filter(function (arg) {
             if (plugin) {
                 plugins.push(plugin);
             } else {
-                console.log("Unable to load plugin " + name + " please make sure that it is installed under at the same level as less");
+                console.log("Unable to load plugin " + name + " please make sure that it is installed under or at the same level as less");
                 console.log();
                 printUsage();
                 currentErrorcode = 1;
@@ -238,7 +238,7 @@ args = args.filter(function (arg) {
             if (plugin) {
                 plugins.push(plugin);
             } else {
-                console.log("Unable to interpret argument " + arg + " - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under at the same level as less");
+                console.log("Unable to interpret argument " + arg + " - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under or at the same level as less");
                 console.log();
                 printUsage();
                 currentErrorcode = 1;
diff --git a/lib/less-node/plugin-loader.js b/lib/less-node/plugin-loader.js
index 428b1ef..06c70a7 100644
--- a/lib/less-node/plugin-loader.js
+++ b/lib/less-node/plugin-loader.js
@@ -12,11 +12,20 @@ PluginLoader.prototype.tryLoadPlugin = function(name, argument) {
                 console.log("plugin " + name + " requires version " + this.versionToString(plugin.minVersion));
                 return null;
             }
-        } else {
-            console.log("plugin has no min version");
         }
         if (argument) {
-            plugin.setOptions(argument);
+            if (!plugin.setOptions) {
+                console.log("options have been provided but the plugin " + name + "does not support any options");
+                return null;
+            }
+            try {
+                plugin.setOptions(argument);
+            }
+            catch(e) {
+                console.log("Error setting options on plugin " + name);
+                console.log(e.message);
+                return null;
+            }
         }
         return plugin;
     }
diff --git a/lib/less/render.js b/lib/less/render.js
index 5013b77..2a164f9 100644
--- a/lib/less/render.js
+++ b/lib/less/render.js
@@ -13,7 +13,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
         }
 
         if (callback) {
-            render(input, options)
+            render.call(this, input, options)
                 .then(function(css) {
                     callback(null, css);
                 },
@@ -23,7 +23,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
         } else {
             var context,
                 rootFileInfo,
-                pluginManager = new PluginManager();
+                pluginManager = new PluginManager(this);
 
             pluginManager.addPlugins(options.plugins);
             options.pluginManager = pluginManager;

-- 
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