[Pkg-javascript-commits] [less.js] 136/285: import managaer related simplifications

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:47 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 b3b8b278bda85d752297ab66cf9858534aa4c054
Author: Luke Page <luke.a.page at gmail.com>
Date:   Mon Sep 22 20:32:46 2014 +0100

    import managaer related simplifications
---
 bin/lessc                       |  1 +
 lib/less/contexts.js            |  2 --
 lib/less/imports.js             | 11 ++++++-----
 lib/less/parser/parser-input.js | 15 ++++-----------
 lib/less/parser/parser.js       |  9 ++++++++-
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/bin/lessc b/bin/lessc
index 4032a4d..c170d00 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -258,6 +258,7 @@ if (output) {
 sourceMapOptions.sourceMapBasepath = options.sourceMapBasepath || (input ? path.dirname(input) : process.cwd());
 
 if (options.sourceMap) {
+    sourceMapOptions.sourceMapInputFilename = input;
     if (!sourceMapOptions.sourceMapFullFilename) {
         if (!output && !sourceMapFileInline) {
             console.log("the sourcemap option only has an optional filename if the css filename is given");
diff --git a/lib/less/contexts.js b/lib/less/contexts.js
index c79349e..0c9b690 100644
--- a/lib/less/contexts.js
+++ b/lib/less/contexts.js
@@ -13,7 +13,6 @@ var copyFromOriginal = function copyFromOriginal(original, destination, properti
 
 var parseCopyProperties = [
     'paths',            // option - unmodified - paths to search for imports on
-    'files',            // list of files that have been imported, used for import-once
     'contents',         // map - filename to contents of all the files
     'contentsIgnoredChars', // map - filename to lines at the begining of each file to ignore
     'relativeUrls',     // option - whether to adjust URL's to be relative
@@ -44,7 +43,6 @@ contexts.parseEnv = function(options) {
 
     if (!this.contents) { this.contents = {}; }
     if (!this.contentsIgnoredChars) { this.contentsIgnoredChars = {}; }
-    if (!this.files) { this.files = {}; }
 
     if (typeof this.paths === "string") { this.paths = [this.paths]; }
 
diff --git a/lib/less/imports.js b/lib/less/imports.js
index bcd5a6c..ebcfc04 100644
--- a/lib/less/imports.js
+++ b/lib/less/imports.js
@@ -8,13 +8,14 @@ module.exports = function(environment) {
     var ImportManager = function(env) {
         this.rootFilename = env && env.filename;
         this.paths = env.paths || [];  // Search paths, when importing
-        this.queue = []; // Files which haven't been imported yet
-        this.files = env.files;        // Holds the imported parse trees
         this.contents = env.contents; // Holds the imported file contents
         this.contentsIgnoredChars = env.contentsIgnoredChars; // lines inserted, not in the original less
         this.mime = env.mime;
         this.error = null;
         this.env = env;
+        // Deprecated? Unused outside of here, could be useful.
+        this.queue = [];        // Files which haven't been imported yet
+        this.files = [];        // Holds the imported parse trees.
     };
     ImportManager.prototype.getAbsolutePath = function(filename) {
         // proxy needed for "DebugInfo"
@@ -28,13 +29,13 @@ module.exports = function(environment) {
         var fileParsedFunc = function (e, root, fullPath) {
             parserImports.queue.splice(parserImports.queue.indexOf(path), 1); // Remove the path from the queue
 
-            var importedPreviously = fullPath === parserImports.rootFilename;
+            var importedEqualsRoot = fullPath === parserImports.rootFilename;
 
-            parserImports.files[fullPath] = root;                        // Store the root
+            parserImports.files[fullPath] = root;
 
             if (e && !parserImports.error) { parserImports.error = e; }
 
-            callback(e, root, importedPreviously, fullPath);
+            callback(e, root, importedEqualsRoot, fullPath);
         };
 
         var newFileInfo = {
diff --git a/lib/less/parser/parser-input.js b/lib/less/parser/parser-input.js
index fc0bf56..39f1e4c 100644
--- a/lib/less/parser/parser-input.js
+++ b/lib/less/parser/parser-input.js
@@ -1,5 +1,5 @@
-var chunker = require('./chunker'),
-    LessError = require('../less-error');
+var chunker = require('./chunker');
+
 module.exports = function() {
     var input,       // LeSS input string
         j,           // current chunk
@@ -211,7 +211,7 @@ module.exports = function() {
         return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA;
     };
 
-    parserInput.start = function(str, chunkInput, env) {
+    parserInput.start = function(str, chunkInput, failFunction) {
         input = str;
         parserInput.i = j = currentPos = furthest = 0;
 
@@ -226,14 +226,7 @@ module.exports = function() {
         // this is officially deprecated but can be switched on via an option
         // in the case it causes too much performance issues.
         if (chunkInput) {
-            chunks = chunker(str, function fail(msg, index) {
-                throw new(LessError)({
-                    index: index,
-                    type: 'Parse',
-                    message: msg,
-                    filename: env.currentFileInfo.filename
-                }, env); //TODO works because env contains contents like importManager
-            });
+            chunks = chunker(str, failFunction);
         } else {
             chunks = [str];
         }
diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js
index 5632e9d..1f77521 100644
--- a/lib/less/parser/parser.js
+++ b/lib/less/parser/parser.js
@@ -113,7 +113,14 @@ var Parser = function Parser(env, imports) {
             // with the `root` property set to true, so no `{}` are
             // output. The callback is called when the input is parsed.
             try {
-                parserInput.start(str, env.chunkInput, env);
+                parserInput.start(str, env.chunkInput, function fail(msg, index) {
+                    throw new(LessError)({
+                        index: index,
+                        type: 'Parse',
+                        message: msg,
+                        filename: env.currentFileInfo.filename
+                    }, imports);
+                });
 
                 root = new(tree.Ruleset)(null, this.parsers.primary());
                 root.root = true;

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