[Pkg-javascript-commits] [less.js] 93/285: Parser no longer requires environment

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:42 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 9d230623d2d330ffc434307948e403784cfa0835
Author: Luke Page <luke.a.page at gmail.com>
Date:   Thu Sep 4 18:42:00 2014 +0100

    Parser no longer requires environment
---
 lib/less/imports.js        | 13 ++++++++++---
 lib/less/non-node-index.js |  4 ++--
 lib/less/parser/parser.js  |  6 ++----
 lib/less/render.js         |  7 ++++---
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/less/imports.js b/lib/less/imports.js
index e31a375..d0e149d 100644
--- a/lib/less/imports.js
+++ b/lib/less/imports.js
@@ -1,5 +1,7 @@
-var contexts = require("./contexts.js");
-var getImportManager = module.exports = function(environment, env, Parser) {
+var contexts = require("./contexts.js"),
+    Parser = require('./parser/parser.js');
+
+var getImportManager = module.exports = function(environment, env) {
     var rootFilename = env && env.filename;
     return {
         paths: env.paths || [],  // Search paths, when importing
@@ -9,6 +11,11 @@ var getImportManager = module.exports = function(environment, env, Parser) {
         contentsIgnoredChars: env.contentsIgnoredChars, // lines inserted, not in the original less
         mime:  env.mime,         // MIME type of .less files
         error: null,             // Error in parsing/evaluating an import
+        getAbsolutePath: function(env, filename) {
+            // proxy needed for "DebugInfo"
+            // I hope one day we can remove this function
+            return environment.getAbsolutePath(env, filename);
+        },
         push: function (path, currentFileInfo, importOptions, callback) {
             var parserImports = this;
             this.queue.push(path);
@@ -68,7 +75,7 @@ var getImportManager = module.exports = function(environment, env, Parser) {
                 if (importOptions.inline) {
                     fileParsedFunc(null, contents, resolvedFilename);
                 } else {
-                    new(Parser)(newEnv, getImportManager(environment, env, Parser)).parse(contents, function (e, root) {
+                    new(Parser)(newEnv, getImportManager(environment, env)).parse(contents, function (e, root) {
                         fileParsedFunc(e, root, resolvedFilename);
                     });
                 }
diff --git a/lib/less/non-node-index.js b/lib/less/non-node-index.js
index 7abfc1b..2b2ed2b 100644
--- a/lib/less/non-node-index.js
+++ b/lib/less/non-node-index.js
@@ -4,12 +4,12 @@ module.exports = function(environment) {
         data: require('./data/index.js'),
         tree: require('./tree/index.js'),
         visitor: require('./visitor/index.js'),
-        Parser: require('./parser/parser.js')(environment),
+        Parser: require('./parser/parser.js'),
         functions: require('./functions/index.js')(environment),
         contexts: require("./contexts.js"),
         environment: environment
     };
-    less.render = require("./render.js")(less.Parser, environment);
+    less.render = require("./render.js")(environment);
 
     return less;
 };
diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js
index c2c2ed1..9e62b9f 100644
--- a/lib/less/parser/parser.js
+++ b/lib/less/parser/parser.js
@@ -4,7 +4,6 @@ var LessError = require('../less-error.js'),
     getParserInput = require("./parser-input.js"),
     utils = require("../utils.js");
 
-module.exports = function(environment) {
 //
 // less.js - parser
 //
@@ -74,7 +73,7 @@ var Parser = function Parser(env, imports) {
 
     function getDebugInfo(index) {
         var filename = env.currentFileInfo.filename;
-        filename = environment.getAbsolutePath(env, filename);
+        filename = imports.getAbsolutePath(env, filename);
 
         return {
             lineNumber: utils.getLocation(index, parserInput.getInput()).line + 1,
@@ -1589,5 +1588,4 @@ Parser.serializeVars = function(vars) {
     return s;
 };
 
-return Parser;
-};
+module.exports = Parser;
diff --git a/lib/less/render.js b/lib/less/render.js
index fcce382..83f9098 100644
--- a/lib/less/render.js
+++ b/lib/less/render.js
@@ -1,8 +1,9 @@
 var PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise,
     contexts = require("./contexts.js"),
-    getImportManager = require("./imports.js");
+    getImportManager = require("./imports.js"),
+    Parser = require('./parser/parser.js');
 
-var render = function(Parser, environment) {
+var render = function(environment) {
     var ParseTree = require("./parse-tree.js")(environment);
     return function (input, options, callback) {
         options = options || {};
@@ -22,7 +23,7 @@ var render = function(Parser, environment) {
                 });
         } else {
             var env = new contexts.parseEnv(options),
-                imports = getImportManager(environment, env, Parser);
+                imports = getImportManager(environment, env);
 
             var parser = new(Parser)(env, imports);
 

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