pax_global_header00006660000000000000000000000064130650507260014516gustar00rootroot0000000000000052 comment=a4d4da4229ab3f60d7a3ef142673af8f5180fd3e map-sources-1.0.0/000077500000000000000000000000001306505072600137525ustar00rootroot00000000000000map-sources-1.0.0/.editorconfig000066400000000000000000000003051306505072600164250ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false map-sources-1.0.0/.eslintrc000066400000000000000000000000301306505072600155670ustar00rootroot00000000000000{ "extends": "gulp" } map-sources-1.0.0/.gitignore000066400000000000000000000012541306505072600157440ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript # Garbage files .DS_Store # Generated by integration tests test/fixtures/tmp test/fixtures/out map-sources-1.0.0/.jscsrc000066400000000000000000000000271306505072600152410ustar00rootroot00000000000000{ "preset": "gulp" } map-sources-1.0.0/.travis.yml000066400000000000000000000001711306505072600160620ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '5' - '4' - '0.12' - '0.10' after_script: - npm run coveralls map-sources-1.0.0/LICENSE000066400000000000000000000021241306505072600147560ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2017 Blaine Bublitz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. map-sources-1.0.0/README.md000066400000000000000000000040011306505072600152240ustar00rootroot00000000000000# @gulp-sourcemaps/map-sources [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] Gulp plugin for mapping sources of a sourcemap. ## Example ```js var mapSources = require('@gulp-sourcemaps/map-sources'); gulp.src(...) .pipe(sourcemaps.init()) .pipe(mapSources(function(sourcePath, file) { return '../' + sourcePath; })) .pipe(sourcemaps.write()) .pipe(gulp.dest(...)) ``` ## API ### `mapSources(mapFn)` Takes a map function as the only argument. Returns an `objectMode` Transform stream. #### `mapFn(sourcePath, file)` The map function is called once per value of the `sources` array of a `sourceMap` attached to each [`Vinyl`][vinyl-url] object passed through the stream. The map function is called with the `sourcePath` string from the `sources` array and the `file` object it originated from. The return value replaces the original value in the array. If a `Vinyl` object doesn't have a `sourceMap` or `sourceMap.sources` property, the file is passed through the stream without having the `mapFn` called. All `sources` are normalized to use `/` instead of `\\` as path separators. ## License MIT [vinyl-url]: https://github.com/gulpjs/vinyl [downloads-image]: http://img.shields.io/npm/dm/@gulp-sourcemaps/map-sources.svg [npm-url]: https://npmjs.org/package/@gulp-sourcemaps/map-sources [npm-image]: http://img.shields.io/npm/v/@gulp-sourcemaps/map-sources.svg [travis-url]: https://travis-ci.org/gulp-sourcemaps/map-sources [travis-image]: http://img.shields.io/travis/gulp-sourcemaps/map-sources.svg?label=travis-ci [appveyor-url]: https://ci.appveyor.com/project/phated/map-sources [appveyor-image]: https://img.shields.io/appveyor/ci/phated/map-sources.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulp-sourcemaps/map-sources [coveralls-image]: http://img.shields.io/coveralls/gulp-sourcemaps/map-sources.svg map-sources-1.0.0/appveyor.yml000066400000000000000000000007211306505072600163420ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # http://www.appveyor.com/docs/lang/nodejs-iojs environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "5" - nodejs_version: "6" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - cmd: npm test build: off # build version format version: "{build}" map-sources-1.0.0/index.js000066400000000000000000000011321306505072600154140ustar00rootroot00000000000000'use strict'; var through = require('through2'); var normalize = require('normalize-path'); function mapSources(mapFn) { function transform(file, _, cb) { if (!file.sourceMap || !file.sourceMap.sources) { return cb(null, file); } function mapper(sourcePath) { var result = sourcePath; if (typeof mapFn === 'function') { result = mapFn(sourcePath, file); } return normalize(result); } file.sourceMap.sources = file.sourceMap.sources.map(mapper); cb(null, file); } return through.obj(transform); } module.exports = mapSources; map-sources-1.0.0/package.json000066400000000000000000000021371306505072600162430ustar00rootroot00000000000000{ "name": "@gulp-sourcemaps/map-sources", "version": "1.0.0", "description": "Gulp plugin for mapping sources of a sourcemap.", "author": "Gulp-sourcemaps Team", "contributors": [ "Blaine Bublitz " ], "repository": "gulp-sourcemaps/map-sources", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "lint": "eslint . && jscs index.js test/", "pretest": "npm run lint", "test": "mocha --async-only", "cover": "istanbul cover _mocha --report lcovonly", "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "normalize-path": "^2.0.1", "through2": "^2.0.3" }, "devDependencies": { "eslint": "^1.7.3", "eslint-config-gulp": "^2.0.0", "expect": "^1.19.0", "istanbul": "^0.4.3", "istanbul-coveralls": "^1.0.3", "jscs": "^2.3.5", "jscs-preset-gulp": "^1.0.0", "mississippi": "^1.3.0", "mocha": "^2.4.5", "vinyl": "^2.0.1" }, "keywords": [ "sourcemap", "sources", "stream" ] } map-sources-1.0.0/test/000077500000000000000000000000001306505072600147315ustar00rootroot00000000000000map-sources-1.0.0/test/.eslintrc000066400000000000000000000000351306505072600165530ustar00rootroot00000000000000{ "extends": "gulp/test" } map-sources-1.0.0/test/index.js000066400000000000000000000123261306505072600164020ustar00rootroot00000000000000'use strict'; var expect = require('expect'); var miss = require('mississippi'); var File = require('vinyl'); var normalize = require('normalize-path'); var mapSources = require('../'); var pipe = miss.pipe; var from = miss.from; var concat = miss.concat; function makeFile() { var file = new File({ cwd: __dirname, base: __dirname + '/assets', path: __dirname + '/assets/helloworld.js', contents: null, }); file.sourceMap = { version: 3, file: 'helloworld.js', names: [], mappings: '', sources: ['helloworld.js', 'helloworld2.js'], }; return file; } describe('mapSources', function() { it('ignores a file without sourceMap property', function(done) { var file = makeFile(); delete file.sourceMap; var spy = expect.createSpy(); function assert(files) { expect(files.length).toEqual(1); expect(spy).toNotHaveBeenCalled(); } pipe([ from.obj([file]), mapSources(spy), concat(assert), ], done); }); it('only ignores a file without sourceMap property', function(done) { var file = makeFile(); delete file.sourceMap; var file2 = makeFile(); function mapFn(sourcePath) { return sourcePath; } var spy = expect.createSpy().andCall(mapFn); function assert(files) { expect(files.length).toEqual(2); // This is 2 because there are 2 sources on file2 // If it were incorrect, it would have been called 4 times expect(spy.calls.length).toEqual(2); } pipe([ from.obj([file, file2]), mapSources(spy), concat(assert), ], done); }); it('ignores a file without sourceMap.sources property', function(done) { var file = makeFile(); delete file.sourceMap.sources; var spy = expect.createSpy(); function assert(files) { expect(files.length).toEqual(1); expect(spy).toNotHaveBeenCalled(); } pipe([ from.obj([file]), mapSources(spy), concat(assert), ], done); }); it('only ignores a file without sourceMap.sources property', function(done) { var file = makeFile(); delete file.sourceMap.sources; var file2 = makeFile(); function mapFn(sourcePath) { return sourcePath; } var spy = expect.createSpy().andCall(mapFn); function assert(files) { expect(files.length).toEqual(2); // This is 2 because there are 2 sources on file2 // If it were incorrect, it would have been called 4 times expect(spy.calls.length).toEqual(2); } pipe([ from.obj([file, file2]), mapSources(spy), concat(assert), ], done); }); it('calls map function on each source', function(done) { var file = makeFile(); function mapFn(sourcePath) { return '/test/' + sourcePath; } function assert(files) { expect(files.length).toEqual(1); expect(files[0].sourceMap.sources).toEqual(['/test/helloworld.js', '/test/helloworld2.js']); } pipe([ from.obj([file]), mapSources(mapFn), concat(assert), ], done); }); it('normalizes Windows paths to unix paths', function(done) { var file = makeFile(); function mapFn(sourcePath) { return '\\test\\' + sourcePath; } function assert(files) { expect(files.length).toEqual(1); expect(files[0].sourceMap.sources).toEqual(['/test/helloworld.js', '/test/helloworld2.js']); } pipe([ from.obj([file]), mapSources(mapFn), concat(assert), ], done); }); it('does not need a map function', function(done) { var file = makeFile(); function assert(files) { expect(files.length).toEqual(1); expect(files[0].sourceMap.sources).toEqual(['helloworld.js', 'helloworld2.js']); } pipe([ from.obj([file]), mapSources(), concat(assert), ], done); }); it('ignores non-function argument', function(done) { var file = makeFile(); function assert(files) { expect(files.length).toEqual(1); expect(files[0].sourceMap.sources).toEqual(['helloworld.js', 'helloworld2.js']); } pipe([ from.obj([file]), mapSources('invalid argument'), concat(assert), ], done); }); it('still normalizes without a map function', function(done) { var file = makeFile(); file.sourceMap.sources = file.sourceMap.sources.map(function(sourcePath) { return '\\test\\' + sourcePath; }); function assert(files) { expect(files.length).toEqual(1); expect(files[0].sourceMap.sources).toEqual(['/test/helloworld.js', '/test/helloworld2.js']); } pipe([ from.obj([file]), mapSources(), concat(assert), ], done); }); it('calls map function with each sourcePath and the vinyl file', function(done) { var file = makeFile(); function mapFn(sourcePath, file) { expect(File.isVinyl(file)).toEqual(true); return file.base + '/' + sourcePath; } function assert(files) { expect(files.length).toEqual(1); var file = files[0]; var base = normalize(file.base); expect(file.sourceMap.sources).toEqual([base + '/helloworld.js', base + '/helloworld2.js']); } pipe([ from.obj([file]), mapSources(mapFn), concat(assert), ], done); }); });