[Pkg-javascript-commits] [less.js] 04/26: Fix the depends option. Fixes #1799

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:25:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.1.0
in repository less.js.

commit 5e4fa2a5a5ad460a3624642896372e39963be2bf
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sat Nov 15 10:12:27 2014 +0000

    Fix the depends option. Fixes #1799
---
 bin/lessc                  | 27 ++++++++-------------------
 lib/less/import-manager.js |  2 +-
 lib/less/parse-tree.js     |  7 +++++++
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/bin/lessc b/bin/lessc
index fe963d7..6cf6cf7 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -353,24 +353,6 @@ var parseLessFile = function (e, data) {
     options.paths = [path.dirname(input)].concat(options.paths);
     options.filename = input;
 
-    if (options.depends) {
-        var parser = new(less.Parser)(options);
-        parser.parse(data, function (err, tree) {
-            if (err) {
-                less.writeError(err, options);
-                currentErrorcode = 1;
-                return;
-            }
-            for(var file in parser.imports.files) {
-                if (parser.imports.files.hasOwnProperty(file)) {
-                    process.stdout.write(file + " ");
-                }
-            }
-            console.log("");
-        });
-        return;
-    }
-
     if (options.lint) {
         options.sourceMap = false;
     }
@@ -403,12 +385,19 @@ var parseLessFile = function (e, data) {
                     ensureDirectory(output);
                     fs.writeFileSync(output, result.css, 'utf8');
                     less.logger.info('lessc: wrote ' + output);
-                } else {
+                } else if (!options.depends) {
                     process.stdout.write(result.css);
                 }
                 if (options.sourceMap && !sourceMapFileInline) {
                     writeSourceMap(result.map);
                 }
+                if (options.depends) {
+                    var depends = "";
+                    for(var i = 0; i < result.imports.length; i++) {
+                        depends += result.imports[i] + " ";
+                    }
+                    console.log(depends);
+                }
             }
         },
         function(err) {
diff --git a/lib/less/import-manager.js b/lib/less/import-manager.js
index 6188b1d..a370e59 100644
--- a/lib/less/import-manager.js
+++ b/lib/less/import-manager.js
@@ -22,7 +22,7 @@ module.exports = function(environment) {
         this.context = context;
         // Deprecated? Unused outside of here, could be useful.
         this.queue = [];        // Files which haven't been imported yet
-        this.files = [];        // Holds the imported parse trees.
+        this.files = {};        // Holds the imported parse trees.
     };
     /**
      * Add an import to be imported
diff --git a/lib/less/parse-tree.js b/lib/less/parse-tree.js
index 6b64709..143cf2e 100644
--- a/lib/less/parse-tree.js
+++ b/lib/less/parse-tree.js
@@ -41,6 +41,13 @@ ParseTree.prototype.toCSS = function(options) {
     if (options.sourceMap) {
         result.map = sourceMapBuilder.getExternalSourceMap();
     }
+
+    result.imports = [];
+    for(var file in this.imports.files) {
+        if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {
+            result.imports.push(file);
+        }
+    }
     return result;
 };
 return ParseTree;

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