[Pkg-javascript-commits] [less.js] 124/285: support min version

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:46 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 86f78fa19704b454704f983a15997fc9453c0432
Author: Luke Page <luke.a.page at gmail.com>
Date:   Thu Sep 18 12:53:05 2014 +0100

    support min version
---
 bin/lessc                            |  2 +-
 lib/less-node/index.js               |  2 ++
 lib/less-node/node-plugin-manager.js | 23 +++++++++++++++++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/bin/lessc b/bin/lessc
index 129b74a..f0a27dd 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -64,7 +64,7 @@ var warningMessages = "";
 var sourceMapFileInline = false;
 
 function printUsage() {
-    require('../lib/less-node/lessc-helper').printUsage();
+    less.lesscHelper.printUsage();
     pluginManager.printUsage();
     continueProcessing = false;
 }
diff --git a/lib/less-node/index.js b/lib/less-node/index.js
index 57174b4..63f2ded 100644
--- a/lib/less-node/index.js
+++ b/lib/less-node/index.js
@@ -7,6 +7,8 @@ var environment = require("./environment"),
 less.createFromEnvironment = createFromEnvironment;
 less.lesscHelper = lesscHelper;
 less.PluginManager = require("./node-plugin-manager");
+less.fs = require("./fs");
+less.environment = environment;
 less.formatError = function(ctx, options) {
     options = options || {};
 
diff --git a/lib/less-node/node-plugin-manager.js b/lib/less-node/node-plugin-manager.js
index 2e06de7..a013fcc 100644
--- a/lib/less-node/node-plugin-manager.js
+++ b/lib/less-node/node-plugin-manager.js
@@ -9,11 +9,34 @@ NodePluginManager.prototype = new PluginManager();
 NodePluginManager.prototype.tryLoadPlugin = function(name, argument) {
     var plugin = this.tryRequirePlugin(name);
     if (plugin) {
+        if (plugin.minVersion) {
+            if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {
+                console.log("plugin " + name + " requires version " + this.versionToString(plugin.minVersion));
+                return false;
+            }
+        } else {
+            console.log("plugin has no min version");
+        }
         this.addPlugin(plugin, argument);
         return true;
     }
     return false;
 };
+NodePluginManager.prototype.compareVersion = function(aVersion, bVersion) {
+    for(var i = 0; i < aVersion.length; i++) {
+        if (aVersion[i] !== bVersion[i]) {
+            return aVersion[i] > bVersion[i] ? -1 : 1;
+        }
+    }
+    return 0;
+};
+NodePluginManager.prototype.versionToString = function(version) {
+    var versionString = "";
+    for(var i = 0; i < version.length; i++) {
+        versionString += (versionString ? "." : "") + version[i];
+    }
+    return versionString;
+};
 NodePluginManager.prototype.tryRequirePlugin = function(name) {
     if (name[0] !== '.') {
         try {

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