rebase-local-map.js 446 B

123456789101112131415
  1. var path = require('path');
  2. function rebaseLocalMap(sourceMap, sourceUri, rebaseTo) {
  3. var currentPath = path.resolve('');
  4. var absoluteUri = path.resolve(currentPath, sourceUri);
  5. var absoluteUriDirectory = path.dirname(absoluteUri);
  6. sourceMap.sources = sourceMap.sources.map(function(source) {
  7. return path.relative(rebaseTo, path.resolve(absoluteUriDirectory, source));
  8. });
  9. return sourceMap;
  10. }
  11. module.exports = rebaseLocalMap;