Convert map files via JSON.parse instead of using string manipulation in minify.js.

Former-commit-id: 185b77d45995f17c586f35d6ad447074d677a6ae
This commit is contained in:
John-David Dalton
2013-02-15 08:58:20 -08:00
parent 02687f3c78
commit 9ccfa5cec9

View File

@@ -369,13 +369,12 @@
if (isMapped) {
var mapOutput = fs.readFileSync(mapPath, 'utf8');
fs.unlinkSync(mapPath);
output = output.replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + path.basename(mapPath)) + '\n*/';
output = output
.replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + path.basename(mapPath)) + '\n*/';
mapOutput = mapOutput
.replace(/("file":)""/, '$1"' + path.basename(outputPath) + '"')
.replace(/("sources":)\["stdin"\]/, '$1["' + path.basename(filePath) + '"]');
mapOutput = JSON.parse(mapOutput);
mapOutput.file = path.basename(outputPath);
mapOutput.sources = [path.basename(filePath)];
mapOutput = JSON.stringify(mapOutput, null, 2);
}
callback(exception, output, mapOutput);
});