concat-with-sourcemaps
Advanced tools
Comparing version 1.0.3 to 1.0.4
32
index.js
@@ -37,3 +37,3 @@ 'use strict'; | ||
Concat.prototype.add = function(filePath, content, sourceMap) { | ||
filePath = unixStylePath(filePath); | ||
filePath = filePath && unixStylePath(filePath); | ||
@@ -83,17 +83,19 @@ if (!Buffer.isBuffer(content)) { | ||
filePath = sourceMap.sources[0]; | ||
for (var i = 1; i <= lines; i++) { | ||
this._sourceMap.addMapping({ | ||
generated: { | ||
line: this.lineOffset + i, | ||
column: (i === 1 ? this.columnOffset : 0) | ||
}, | ||
original: { | ||
line: i, | ||
column: 0 | ||
}, | ||
source: filePath | ||
}); | ||
if (filePath) { | ||
for (var i = 1; i <= lines; i++) { | ||
this._sourceMap.addMapping({ | ||
generated: { | ||
line: this.lineOffset + i, | ||
column: (i === 1 ? this.columnOffset : 0) | ||
}, | ||
original: { | ||
line: i, | ||
column: 0 | ||
}, | ||
source: filePath | ||
}); | ||
} | ||
if (sourceMap && sourceMap.sourcesContent) | ||
this._sourceMap.setSourceContent(filePath, sourceMap.sourcesContent[0]); | ||
} | ||
if (sourceMap && sourceMap.sourcesContent) | ||
this._sourceMap.setSourceContent(filePath, sourceMap.sourcesContent[0]); | ||
} | ||
@@ -100,0 +102,0 @@ if (lines > 1) |
{ | ||
"name": "concat-with-sourcemaps", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Concatenate file contents with a custom separator and generate a source map", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/floridoo/concat-with-sourcemaps", |
@@ -8,2 +8,3 @@ ## Concat with source maps [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] | ||
var concat = new Concat(true, 'all.js', '\n'); | ||
concat.add(null, "// (c) John Doe"); | ||
concat.add('file1.js', file1Content); | ||
@@ -30,3 +31,3 @@ concat.add('file2.js', file2Content, file2SourceMap); | ||
Parameters: | ||
- fileName: file name of the input file | ||
- fileName: file name of the input file (can be null for content without a file reference, e.g. a license comment) | ||
- content: content (Buffer or string) of the input file | ||
@@ -33,0 +34,0 @@ - sourceMap: optional source map of the input file (string). Will be merged into the output source map. |
7383
108
46