sourcemaps.js 776 B

12345678910111213141516171819202122232425262728293031323334
  1. // Generated by CoffeeScript 1.12.1
  2. (function() {
  3. var W, fs, node;
  4. W = require('when');
  5. node = require('when/node');
  6. fs = require('fs');
  7. /**
  8. * Reads a source map's sources and inlines them in the `sourcesContents` key,
  9. * returning the full map.
  10. *
  11. * @param {Object} map - source map v3
  12. * @return {Promise} a promise for the sourcemap updated with contents
  13. */
  14. exports.inline_sources = function(map) {
  15. if (map.sourcesContent) {
  16. return W.resolve(map);
  17. }
  18. return W.map(map.sources, function(source) {
  19. return node.call(fs.readFile.bind(fs), source, 'utf8');
  20. }).then(function(contents) {
  21. map.sourcesContent = contents;
  22. return map;
  23. })["catch"](function() {
  24. return map;
  25. });
  26. };
  27. }).call(this);