From 409bb1e9844e57a0ba237911f3518bc55de44a21 Mon Sep 17 00:00:00 2001 From: Ako Tulu Date: Tue, 12 Dec 2023 17:26:08 +0200 Subject: [PATCH] Updated dependencies to latest and corrected code. --- index.js | 45 +++++++++++++++++++++++---------------------- package.json | 20 ++++++++++---------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/index.js b/index.js index 8da21f4..984a086 100644 --- a/index.js +++ b/index.js @@ -124,28 +124,29 @@ module.exports = function(opt) { sourceMap: !!file.sourceMap }; - try { - mangled = uglify.minify(String(file.contents), uglifyOptions); - min_file.contents = new Buffer(mangled.code.replace(reSourceMapComment, '')); - } catch (e) { - this.emit('end'); - return callback(new PluginError('gulp-minify', formatError(e, file))); - } - - if (file.sourceMap) { - min_file.sourceMap = JSON.parse(mangled.map); - min_file.sourceMap.sourcesContent = originalSourceMap.sourcesContent; - min_file.sourceMap.sources = originalSourceMap.sources; - } - - this.push(min_file); - - if (options.noSource !== true) { - file.path = file.path.replace(jsExtensions, ext.src); - this.push(file); - } - - callback(); + (uglify.minify(String(file.contents), uglifyOptions)) + .then((mangled) => { + min_file.contents = new Buffer(mangled.code.replace(reSourceMapComment, '')); + + if (file.sourceMap) { + min_file.sourceMap = JSON.parse(mangled.map); + min_file.sourceMap.sourcesContent = originalSourceMap.sourcesContent; + min_file.sourceMap.sources = originalSourceMap.sources; + } + + this.push(min_file); + + if (options.noSource !== true) { + file.path = file.path.replace(jsExtensions, ext.src); + this.push(file); + } + + callback(); + }) + .catch(e => { + this.emit('end'); + callback(new PluginError('gulp-minify', formatError(e, file))); + }) } return through.obj(minify); diff --git a/package.json b/package.json index 5616209..9049cb8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-minify", - "version": "3.1.0", + "version": "3.2.0", "description": "Js minify plugin for gulp", "main": "index.js", "scripts": { @@ -15,12 +15,12 @@ }, "author": "308512341@qq.com", "dependencies": { - "ansi-colors": "^1.0.1", - "minimatch": "^3.0.2", - "plugin-error": "^0.1.2", - "terser": "^3.7.6", - "through2": "^2.0.3", - "vinyl": "^2.1.0" + "ansi-colors": "^4.1.3", + "minimatch": "^9.0.3", + "plugin-error": "^2.0.1", + "terser": "^5.26.0", + "through2": "^4.0.2", + "vinyl": "^3.0.0" }, "license": "ISC", "bugs": { @@ -29,9 +29,9 @@ "homepage": "https://github.com/hustxiaoc/gulp-minify", "readmeFilename": "README.md", "devDependencies": { - "gulp": "^4.0.0", - "mocha": "^5.2.0", - "rimraf": "^2.6.2" + "gulp": "^4.0.2", + "mocha": "^10.2.0", + "rimraf": "^5.0.5" }, "engines": { "node": ">= 6.0.0"