From 5a5a6fb504d71fc69187ed88788978ff39ad0fdf Mon Sep 17 00:00:00 2001 From: weyusi Date: Tue, 23 Apr 2019 12:30:47 +0930 Subject: [PATCH] fix: neat_js exclude delete operator previously remove reference including 'options.exclude', use Object.assign to clone 'options' object to prevent that. https://stackoverflow.com/a/33053362 --- lib/filter.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/filter.js b/lib/filter.js index 53f9114..872c281 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -72,14 +72,14 @@ function logicJs (str, data) { } // Terser doesn't like unsupported options - delete options.enable - delete options.exclude - let jsLogger = options.logger - delete options.logger + const jsOptions = Object.assign({}, options) + delete jsOptions.enable + delete jsOptions.exclude + delete jsOptions.logger - let result = Terser.minify(str, options) + let result = Terser.minify(str, jsOptions) let saved = ((str.length - result.code.length) / str.length * 100).toFixed(2) - if (jsLogger) { + if (options.logger) { let log = hexo.log || console.log log.log('Minify the js: %s [%s saved]', path, saved + '%') }