mirror of https://github.com/curbengh/hexo-yam
refactor: use nanomatch.some()
.some supports string and array patterns, so no need for loop. https://github.com/micromatch/nanomatch#some
This commit is contained in:
parent
fa2efb9bd3
commit
1de8ec2cd9
|
@ -15,12 +15,10 @@ function logicHtml (str, data) {
|
||||||
|
|
||||||
let path = data.path
|
let path = data.path
|
||||||
let exclude = options.exclude
|
let exclude = options.exclude
|
||||||
if (exclude && !Array.isArray(exclude)) exclude = [exclude]
|
|
||||||
|
|
||||||
|
// Return if a path matches exclusion pattern
|
||||||
if (path && exclude && exclude.length) {
|
if (path && exclude && exclude.length) {
|
||||||
for (let i = 0, len = exclude.length; i < len; i++) {
|
if (nanomatch.some(path, exclude, { matchBase: true })) return str
|
||||||
if (nanomatch.isMatch(path, exclude[i], { matchBase: true })) return str
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = Htmlminifier(str, options)
|
let result = Htmlminifier(str, options)
|
||||||
|
@ -40,12 +38,10 @@ function logicCss (str, data) {
|
||||||
|
|
||||||
let path = data.path
|
let path = data.path
|
||||||
let exclude = options.exclude
|
let exclude = options.exclude
|
||||||
if (exclude && !Array.isArray(exclude)) exclude = [exclude]
|
|
||||||
|
|
||||||
|
// Return if a path matches exclusion pattern
|
||||||
if (path && exclude && exclude.length) {
|
if (path && exclude && exclude.length) {
|
||||||
for (let i = 0, len = exclude.length; i < len; i++) {
|
if (nanomatch.some(path, exclude, { matchBase: true })) return str
|
||||||
if (nanomatch.isMatch(path, exclude[i], { matchBase: true })) return str
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
@ -69,12 +65,10 @@ function logicJs (str, data) {
|
||||||
|
|
||||||
let path = data.path
|
let path = data.path
|
||||||
let exclude = options.exclude
|
let exclude = options.exclude
|
||||||
if (exclude && !Array.isArray(exclude)) exclude = [exclude]
|
|
||||||
|
|
||||||
|
// Return if a path matches exclusion pattern
|
||||||
if (path && exclude && exclude.length) {
|
if (path && exclude && exclude.length) {
|
||||||
for (let i = 0, len = exclude.length; i < len; i++) {
|
if (nanomatch.some(path, exclude, { matchBase: true })) return str
|
||||||
if (nanomatch.isMatch(path, exclude[i], { matchBase: true })) return str
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terser doesn't like unsupported options
|
// Terser doesn't like unsupported options
|
||||||
|
|
Loading…
Reference in New Issue