diff options
author | Devon Govett <devongovett@gmail.com> | 2013-02-10 10:06:13 -0800 |
---|---|---|
committer | Devon Govett <devongovett@gmail.com> | 2013-02-10 10:06:13 -0800 |
commit | f2767452e609cefecd8bff987c077d956b7b1534 (patch) | |
tree | 1a4f289b00726cdaecae78b33518bbb7682c0601 /tools | |
parent | 916faf0a486fb540273629ef6c80d1087d1fd4ae (diff) | |
download | tracifyjs-f2767452e609cefecd8bff987c077d956b7b1534.tar.gz tracifyjs-f2767452e609cefecd8bff987c077d956b7b1534.zip |
Allow inSourceMap to be a generated JSON source map instead of just a file name
Diffstat (limited to 'tools')
-rw-r--r-- | tools/node.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/node.js b/tools/node.js index cf87628d..c0dd3dbc 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 + "" }; }; |