From f0d27b9b5ea7ac2ccda231f1633a012a28a1a8b6 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Fri, 2 Aug 2019 17:15:03 +0930 Subject: [PATCH] refactor: replace minimatch with micromatch --- lib/filter.js | 9 +++------ package.json | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/filter.js b/lib/filter.js index 488cbf2..2897b7a 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -1,19 +1,16 @@ 'use strict'; const CleanCSS = require('clean-css'); -const minimatch = require('minimatch'); +const micromatch = require('micromatch'); const Promise = require('bluebird'); module.exports = function(str, data) { const options = this.config.clean_css; const path = data.path; - let exclude = options.exclude; - if (exclude && !Array.isArray(exclude)) exclude = [exclude]; + const exclude = options.exclude; if (path && exclude && exclude.length) { - for (let i = 0, len = exclude.length; i < len; i++) { - if (minimatch(path, exclude[i])) return str; - } + if (micromatch.isMatch(path, exclude, { basename: true })) return str; } return new Promise((resolve, reject) => { diff --git a/package.json b/package.json index 1d6733e..8be00d0 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dependencies": { "bluebird": "^3.5.5", "clean-css": "^4.2.1", - "minimatch": "^3.0.4" + "micromatch": "^4.0.2" }, "devDependencies": { "chai": "^4.2.0",