Skip to content

Commit

Permalink
Merge branch '1.X'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmccready committed Feb 5, 2017
2 parents 2e9f33f + d5c71b6 commit 8166cbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ gulp.src(['src/test.js', 'src/testdir/test2.js'], { base: 'src' })

- `mapSources`

This option gives full control over the source paths. It takes a function that is called for every source and receives the default source path as a parameter.
This option gives full control over the source paths. It takes a function that is called for every source and receives the default source path as a parameter and the original vinyl file.

Example:
```javascript
Expand All @@ -287,7 +287,7 @@ gulp.src(['src/test.js', 'src/testdir/test2.js'], { base: 'src' })
.pipe(plugin1())
.pipe(plugin2())
.pipe(sourcemaps.write('../maps', {
mapSources: function(sourcePath) {
mapSources: function(sourcePath, file) {
// source paths are prefixed with '../src/'
return '../src/' + sourcePath;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-sourcemaps",
"version": "2.4.0",
"version": "2.4.1",
"description": "Source map support for Gulp.js",
"homepage": "http://github.com/floridoo/gulp-sourcemaps",
"repository": "git://github.com/floridoo/gulp-sourcemaps.git",
Expand Down
4 changes: 3 additions & 1 deletion src/write/index.internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ module.exports = function(destPath, options) {
//NOTE: make sure source mapping happens after content has been loaded
if (options.mapSources && typeof options.mapSources === 'function') {
debug(utils.logCb('function'));
file.sourceMap.sources = file.sourceMap.sources.map(options.mapSources);
file.sourceMap.sources = file.sourceMap.sources.map(function (filePath) {
return options.mapSources(filePath, file);
});
return;
}

Expand Down
3 changes: 2 additions & 1 deletion test/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ test('write: should be able to fully control sourceMappingURL by the option sour
test('write: should allow to change sources', function(t) {
var file = makeFile();
var pipeline = sourcemaps.write({
mapSources: function(sourcePath) {
mapSources: function(sourcePath, f) {
t.equal(file,f, 'vinyl file gets passed');
return '../src/' + sourcePath;
}
});
Expand Down

0 comments on commit 8166cbe

Please sign in to comment.