Skip to content

Commit 2b2a275

Browse files
committed
bump 2.3.1 for mapSouces bug fix issue #270
2 parents faa0614 + d7c99a7 commit 2b2a275

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-sourcemaps",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "Source map support for Gulp.js",
55
"homepage": "http://github.com/floridoo/gulp-sourcemaps",
66
"repository": "git://github.com/floridoo/gulp-sourcemaps.git",
@@ -47,6 +47,7 @@
4747
"http-server": "0.9.0",
4848
"istanbul": "0.X",
4949
"jshint": "2.X",
50+
"lodash": "4.17.4",
5051
"object-assign": "^4.1.0",
5152
"tape": "4.X"
5253
},

src/write/index.internals.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,18 @@ module.exports = function(destPath, options) {
3939

4040
file.sourceMap.sources = file.sourceMap.sources.map(function(filePath) {
4141
// keep the references files like ../node_modules within the sourceRoot
42+
debug(utils.logCb("filePath: " + filePath));
43+
debug(utils.logCb("file.path: " + file.path));
44+
debug(utils.logCb("file.cwd: " + file.cwd));
45+
debug(utils.logCb("file.base: " + file.base));
46+
4247
if (!file.dirname){
43-
filePath = file.path.replace(file.cwd, '');
44-
} else
45-
filePath = path.resolve(file.dirname || '', filePath).replace(file.cwd, '');
48+
debug(utils.logCb('!file.dirname'));
49+
filePath = path.join(file.base, filePath).replace(file.cwd, '');
50+
} else {
51+
debug(utils.logCb('file.dirname: ' + file.dirname));
52+
filePath = path.resolve(file.dirname, filePath).replace(file.cwd, '');
53+
}
4654

4755
return unixStylePath(filePath);
4856
});

test/assets/test3.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('three');

test/assets/test4.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('four');

test/integration.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var debug = require('debug-fabulous')()(PLUGIN_NAME + ':test:integration');
88
var join = require('path').join;
99
var fs = require('fs');
1010
var sourceContent = fs.readFileSync(join(__dirname, 'assets/helloworld.js')).toString();
11+
var _ = require('lodash');
1112

1213

1314
function base64JSON(object) {
@@ -229,3 +230,31 @@ test('combined: mapped preExisting with two tasks', function(t) {
229230
});
230231
});
231232
});
233+
234+
// - thanks @twiggy https://github.com/floridoo/gulp-sourcemaps/issues/270#issuecomment-271723208
235+
test('sources: is valid with concat', function(t) {
236+
237+
gulp.src([
238+
join(__dirname, './assets/test3.js'),
239+
join(__dirname, './assets/test4.js'),
240+
])
241+
.pipe(sourcemaps.init())
242+
.pipe($.concat("index.js"))
243+
.pipe(sourcemaps.write('.'))
244+
.pipe(gulp.dest('tmp/sources_concat'))
245+
.on('data', function(file) {
246+
if (!/.*\.map/.test(file.path)) return;
247+
248+
var contents = JSON.parse(file.contents.toString());
249+
_.each(contents.sources, function(s, i){
250+
t.deepEqual(s, "/test/assets/test" + (i+3) + ".js", "source is correct, test" + (i+3) + ".js");
251+
});
252+
})
253+
.on('error', function() {
254+
t.fail('emitted error');
255+
t.end();
256+
}).on('finish', function(){
257+
moveHtml('sources_concat', t);
258+
});
259+
260+
});

0 commit comments

Comments
 (0)