From 5e19490e440437b4df7b089c2f3f54dc4f3e1cd9 Mon Sep 17 00:00:00 2001 From: weyusi Date: Mon, 22 Apr 2019 21:40:15 +0930 Subject: [PATCH] refactor: switch minimatch to nanomatch https://github.com/micromatch/nanomatch --- README.md | 6 +++--- lib/filter.js | 8 ++++---- package.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 329ee9d..503fee4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ neat_html: ``` - **enable** - Enable the plugin. Defaults to `true`. - **logger** - Verbose output. Defaults to `false`. -- **exclude** - Exclude files +- **exclude** - Exclude files. Support [wildcard](https://github.com/micromatch/nanomatch#features) pattern. For more options, see [HTMLMinifier](https://github.com/kangax/html-minifier). @@ -50,7 +50,7 @@ neat_css: ``` - **enable** - Enable the plugin. Defaults to `true`. - **logger** - Verbose output. Defaults to `false`. -- **exclude** - Exclude files +- **exclude** - Exclude files. Support wilcard pattern. ---------- @@ -65,7 +65,7 @@ neat_js: - **logger** - Verbose output. Defaults to `false`. - **output** - Output options - **compress** - Compress options -- **exclude** - Exclude files +- **exclude** - Exclude files. Support wilcard pattern. For more options, see [UglifyJS](https://github.com/mishoo/UglifyJS2). diff --git a/lib/filter.js b/lib/filter.js index 5856c76..f934cff 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -3,7 +3,7 @@ const CleanCSS = require('clean-css') const Terser = require('terser') const Htmlminifier = require('html-minifier').minify -const minimatch = require('minimatch') +const nanomatch = require('nanomatch') const zlib = require('zlib') const br = require('iltorb') @@ -19,7 +19,7 @@ function logicHtml (str, data) { if (path && exclude && exclude.length) { for (let i = 0, len = exclude.length; i < len; i++) { - if (minimatch(path, exclude[i], { matchBase: true })) return str + if (nanomatch.isMatch(path, exclude[i], { matchBase: true })) return str } } @@ -44,7 +44,7 @@ function logicCss (str, data) { if (path && exclude && exclude.length) { for (let i = 0, len = exclude.length; i < len; i++) { - if (minimatch(path, exclude[i], { matchBase: true })) return str + if (nanomatch.isMatch(path, exclude[i], { matchBase: true })) return str } } @@ -73,7 +73,7 @@ function logicJs (str, data) { if (path && exclude && exclude.length) { for (let i = 0, len = exclude.length; i < len; i++) { - if (minimatch(path, exclude[i], { matchBase: true })) return str + if (nanomatch.isMatch(path, exclude[i], { matchBase: true })) return str } } diff --git a/package.json b/package.json index daf5efa..42a65ae 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "clean-css": "^4.2.1", "html-minifier": "^4.0.0", "iltorb": "^2.4.2", - "minimatch": "^3.0.4", + "nanomatch": "^1.2.13", "terser": "^3.17.0" }, "keywords": [