Created
August 31, 2016 13:40
-
-
Save nLight/3cce6b2d045d3af5305d602e7ce7756d to your computer and use it in GitHub Desktop.
Unmap source map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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