[Pkg-javascript-commits] [node-source-map-support] 01/06: New upstream version 0.5.2+ds

Julien Puydt julien.puydt at laposte.net
Mon Jan 22 06:45:00 UTC 2018


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

jpuydt-guest pushed a commit to branch master
in repository node-source-map-support.

commit 056457dfb321b9d14498cf4de969af1d7d2d30f8
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Mon Jan 22 07:39:15 2018 +0100

    New upstream version 0.5.2+ds
---
 README.md             | 24 +++++++++++++++++-------
 package.json          |  2 +-
 source-map-support.js | 16 +++++++++++++++-
 3 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index 0144e1c..0e85cc1 100644
--- a/README.md
+++ b/README.md
@@ -11,13 +11,7 @@ This module provides source map support for stack traces in node via the [V8 sta
 $ npm install source-map-support
 ```
 
-Source maps can be generated using libraries such as [source-map-index-generator](https://github.com/twolfson/source-map-index-generator). Once you have a valid source map, insert the following line at the top of your compiled code:
-
-```js
-require('source-map-support').install();
-```
-
-And place a source mapping comment somewhere in the file (usually done automatically or with an option by your transpiler):
+Source maps can be generated using libraries such as [source-map-index-generator](https://github.com/twolfson/source-map-index-generator). Once you have a valid source map, place a source mapping comment somewhere in the file (usually done automatically or with an option by your transpiler):
 
 ```
 //# sourceMappingURL=path/to/source.map
@@ -27,6 +21,22 @@ If multiple sourceMappingURL comments exist in one file, the last sourceMappingU
 respected (e.g. if a file mentions the comment in code, or went through multiple transpilers).
 The path should either be absolute or relative to the compiled file.
 
+From here you have two options.
+
+##### CLI Usage
+
+```bash
+node -r source-map-support/register compiled.js
+```
+
+##### Programmatic Usage
+
+Put the following line at the top of the compiled file.
+
+```js
+require('source-map-support').install();
+```
+
 It is also possible to install the source map support directly by
 requiring the `register` module which can be handy with ES6:
 
diff --git a/package.json b/package.json
index b996306..1da497a 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "source-map-support",
   "description": "Fixes stack traces for files with source maps",
-  "version": "0.5.0",
+  "version": "0.5.2",
   "main": "./source-map-support.js",
   "scripts": {
     "build": "node build.js",
diff --git a/source-map-support.js b/source-map-support.js
index abd8886..fca4bcc 100644
--- a/source-map-support.js
+++ b/source-map-support.js
@@ -64,6 +64,14 @@ var retrieveFile = handlerExec(retrieveFileHandlers);
 retrieveFileHandlers.push(function(path) {
   // Trim the path to make sure there is no extra whitespace.
   path = path.trim();
+  if (/^file:/.test(path)) {
+    // existsSync/readFileSync can't handle file protocol, but once stripped, it works
+    path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) {
+      return drive ?
+        '' : // file:///C:/dir/file -> C:/dir/file
+        '/'; // file:///root-dir/file -> /root-dir/file
+    });
+  }
   if (path in fileContentsCache) {
     return fileContentsCache[path];
   }
@@ -91,12 +99,18 @@ retrieveFileHandlers.push(function(path) {
 });
 
 // Support URLs relative to a directory, but be careful about a protocol prefix
-// in case we are in the browser (i.e. directories may start with "http://")
+// in case we are in the browser (i.e. directories may start with "http://" or "file:///")
 function supportRelativeURL(file, url) {
   if (!file) return url;
   var dir = path.dirname(file);
   var match = /^\w+:\/\/[^\/]*/.exec(dir);
   var protocol = match ? match[0] : '';
+  var startPath = dir.slice(protocol.length);
+  if (protocol && /^\/\w\:/.test(startPath)) {
+    // handle file:///C:/ paths
+    protocol += '/';
+    return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
+  }
   return protocol + path.resolve(dir.slice(protocol.length), url);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-source-map-support.git



More information about the Pkg-javascript-commits mailing list