[Pkg-javascript-commits] [node-convert-source-map] 01/08: Imported Upstream version 1.2.0

Ross Gammon ross-guest at moszumanska.debian.org
Wed Mar 16 22:01:57 UTC 2016


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

ross-guest pushed a commit to branch master
in repository node-convert-source-map.

commit f1b848431ca9498a6136f5c8e9a2b546de02d974
Author: Ross Gammon <rossgammon at mail.dk>
Date:   Tue Mar 15 22:18:23 2016 +0100

    Imported Upstream version 1.2.0
---
 README.md                  | 8 ++++++++
 index.js                   | 5 +++++
 package.json               | 2 +-
 test/convert-source-map.js | 6 ++++++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e415fec..8ce7d48 100644
--- a/README.md
+++ b/README.md
@@ -117,5 +117,13 @@ Returns the regex used to find source map comments.
 
 Returns the regex used to find source map comments pointing to map files.
 
+### generateMapFileComment(file, [options])
+
+Returns a comment that links to an external source map via `file`.
+
+By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would normally see in a JS source file.
+
+When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
+
 
 [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/thlorenz/convert-source-map/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
diff --git a/index.js b/index.js
index bfe92d1..a8b6dbd 100644
--- a/index.js
+++ b/index.js
@@ -141,6 +141,11 @@ exports.removeMapFileComments = function (src) {
   return src.replace(mapFileCommentRx, '');
 };
 
+exports.generateMapFileComment = function (file, options) {
+  var data = 'sourceMappingURL=' + file;
+  return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
+};
+
 Object.defineProperty(exports, 'commentRegex', {
   get: function getCommentRegex () {
     commentRx.lastIndex = 0;
diff --git a/package.json b/package.json
index e4e19e2..94c09f1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "convert-source-map",
-  "version": "1.1.3",
+  "version": "1.2.0",
   "description": "Converts a source-map from/to  different formats and allows adding/changing properties.",
   "main": "index.js",
   "scripts": {
diff --git a/test/convert-source-map.js b/test/convert-source-map.js
index 9bd3ba9..ea243f5 100644
--- a/test/convert-source-map.js
+++ b/test/convert-source-map.js
@@ -48,6 +48,12 @@ test('to multi-line map', function (t) {
   t.end();
 })
 
+test('to map file comment', function (t) {
+  t.equal(convert.generateMapFileComment('index.js.map'), '//# sourceMappingURL=index.js.map');
+  t.equal(convert.generateMapFileComment('index.css.map', { multiline: true }), '/*# sourceMappingURL=index.css.map */');
+  t.end();
+})
+
 test('from source', function (t) {
   var foo = [
       'function foo() {'

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



More information about the Pkg-javascript-commits mailing list