From f2767452e609cefecd8bff987c077d956b7b1534 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 10 Feb 2013 10:06:13 -0800 Subject: [PATCH] Allow inSourceMap to be a generated JSON source map instead of just a file name --- tools/node.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/node.js b/tools/node.js index cf87628d8d4..c0dd3dbc4e7 100644 --- a/tools/node.js +++ b/tools/node.js @@ -92,17 +92,18 @@ exports.minify = function(files, options) { } // 4. output - var map = null; - var inMap = null; - if (options.inSourceMap) { + var inMap = options.inSourceMap; + var output = {}; + if (typeof options.inSourceMap == "string") { inMap = fs.readFileSync(options.inSourceMap, "utf8"); } - if (options.outSourceMap) map = UglifyJS.SourceMap({ - file: options.outSourceMap, - orig: inMap, - root: options.sourceRoot - }); - var output = { source_map: map }; + if (options.outSourceMap) { + output.source_map = UglifyJS.SourceMap({ + file: options.outSourceMap, + orig: inMap, + root: options.sourceRoot + }); + } if (options.output) { UglifyJS.merge(output, options.output); } @@ -110,7 +111,7 @@ exports.minify = function(files, options) { toplevel.print(stream); return { code : stream + "", - map : map + "" + map : output.source_map + "" }; };