[Pkg-javascript-commits] [less.js] 193/285: Fix default rootpath. Do not apply to sourcemap filename. Replace windows directory seperators.

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:53 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 fde35b7c1c424b9ea5457147284fe633b06bfdc4
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sun Oct 19 18:21:49 2014 +0100

    Fix default rootpath. Do not apply to sourcemap filename. Replace windows directory seperators.
---
 .gitignore                    |  1 +
 Gruntfile.js                  |  4 ++--
 bin/lessc                     | 13 ++++++++++---
 lib/less/source-map-output.js | 17 ++++++++++-------
 4 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore
index 55e880c..e144571 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@ npm-debug.log
 # project-specific
 tmp
 test/browser/less.js
+test/sourcemaps/**/*.map
 test/sourcemaps/*.map
 test/sourcemaps/*.css
 
diff --git a/Gruntfile.js b/Gruntfile.js
index c2858b2..0958a51 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -38,8 +38,8 @@ module.exports = function (grunt) {
             },
             "sourcemap-test": {
                 command: [
-                    'node bin/lessc --source-map --source-map-map-inline test/less/import.less test/sourcemaps/import.css',
-                    'node bin/lessc --source-map --source-map-map-inline test/less/sourcemaps/basic.less test/sourcemaps/basic.css'
+                    'node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/import.less test/sourcemaps/import.css',
+                    'node bin/lessc --source-map test/less/sourcemaps/basic.less test/sourcemaps/basic.css'
                 ].join('&&')
             }
         },
diff --git a/bin/lessc b/bin/lessc
index fe65b4f..b4e3a4a 100755
--- a/bin/lessc
+++ b/bin/lessc
@@ -264,9 +264,8 @@ if (output) {
     }
 }
 
-sourceMapOptions.sourceMapBasepath = options.sourceMapBasepath || (input ? path.dirname(input) : process.cwd());
-
 if (options.sourceMap) {
+
     sourceMapOptions.sourceMapInputFilename = input;
     if (!sourceMapOptions.sourceMapFullFilename) {
         if (!output && !sourceMapFileInline) {
@@ -293,6 +292,15 @@ if (options.sourceMap) {
     }
 }
 
+sourceMapOptions.sourceMapBasepath = sourceMapOptions.sourceMapBasepath || (input ? path.dirname(input) : process.cwd());
+
+if (!sourceMapOptions.sourceMapRootpath) {
+    var pathToMap = path.dirname(sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename),
+        pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename);
+    sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
+}
+
+
 if (! input) {
     console.log("lessc: no input files");
     console.log("");
@@ -364,7 +372,6 @@ var parseLessFile = function (e, data) {
     if (options.lint) {
         options.sourceMap = false;
     }
-    sourceMapOptions.sourceMapRootpath = options.sourceMapRootpath || "";
     sourceMapOptions.sourceMapFileInline = sourceMapFileInline;
 
     if (options.sourceMap) {
diff --git a/lib/less/source-map-output.js b/lib/less/source-map-output.js
index 6c78a47..8f5b45a 100644
--- a/lib/less/source-map-output.js
+++ b/lib/less/source-map-output.js
@@ -5,21 +5,24 @@ module.exports = function (environment) {
         this._rootNode = options.rootNode;
         this._contentsMap = options.contentsMap;
         this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;
-        this._sourceMapFilename = options.sourceMapFilename;
+        this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/');
         this._outputFilename = options.outputFilename;
         this.sourceMapURL = options.sourceMapURL;
         if (options.sourceMapBasepath) {
             this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/');
         }
-        this._sourceMapRootpath = options.sourceMapRootpath;
+        if (options.sourceMapRootpath) {
+            this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/');
+            if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length-1) !== '/') {
+                this._sourceMapRootpath += '/';
+            }
+        } else {
+            this._sourceMapRootpath = "";
+        }
         this._outputSourceFiles = options.outputSourceFiles;
         this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();
         this._sourceMapFileInline = options.sourceMapFileInline;
 
-        if (this._sourceMapRootpath && this._sourceMapRootpath.charAt(this._sourceMapRootpath.length-1) !== '/') {
-            this._sourceMapRootpath += '/';
-        }
-
         this._lineNumber = 0;
         this._column = 0;
     };
@@ -121,7 +124,7 @@ module.exports = function (environment) {
             if (this.sourceMapURL) {
                 sourceMapURL = this.sourceMapURL;
             } else if (this._sourceMapFilename) {
-                sourceMapURL = this.normalizeFilename(this._sourceMapFilename);
+                sourceMapURL = this._sourceMapFilename;
             }
             this.sourceMapURL = sourceMapURL;
 

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