From 203ecaf85ba7ad714e77c78b2102309d5581948c Mon Sep 17 00:00:00 2001 From: Sergej Tatarincev Date: Tue, 9 Oct 2012 12:52:28 +0300 Subject: [PATCH] Fix nodejs minify without inSourceMap exception When inSourceMap is omitted fs.readFile throws exception. Fixed version calls fs.readFile only when inSourceMap argument is present --- tools/node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/node.js b/tools/node.js index bf47abad..fccdd83f 100644 --- a/tools/node.js +++ b/tools/node.js @@ -92,9 +92,13 @@ exports.minify = function(files, options) { // 4. output var map = null; + var inMap = null; + if (options.inSourceMap) { + inMap = fs.readFileSync(options.inSourceMap, "utf8"); + } if (options.outSourceMap) map = UglifyJS.SourceMap({ file: options.outSourceMap, - orig: fs.readFileSync(options.inSourceMap, "utf8") + orig: inMap }); var stream = UglifyJS.OutputStream({ source_map: map }); toplevel.print(stream); -- 2.34.1