Skip to content

Instantly share code, notes, and snippets.

@nLight
Created August 31, 2016 13:40
Show Gist options
  • Save nLight/3cce6b2d045d3af5305d602e7ce7756d to your computer and use it in GitHub Desktop.
Save nLight/3cce6b2d045d3af5305d602e7ce7756d to your computer and use it in GitHub Desktop.
Unmap source map
var sourceMap = require('source-map');
var https = require('https');
var fs = require('fs');
var args = process.argv.slice(2);
if(args.length === 0) {
console.log("Usage: node index.js https://url.to/script.js:<line>:<column>");
return;
}
var match = args[0].match(/(.*?):(\d+):(\d+)$/);
var url = match[1];
var mapFileURL = url + ".map";
var line = match[2];
var column = match[3];
var request = https.get(mapFileURL, function(response) {
var data = "";
response.on('data', function(chunk) {
data += chunk;
});
response.on('end', () => {
var smc = new sourceMap.SourceMapConsumer(JSON.parse(data));
console.log(smc.originalPositionFor({
line: parseInt(line, 10),
column: parseInt(column, 10)
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment