Merge pull request #142 from iptv-org/update-file-js

Update file.js
This commit is contained in:
Aleksandr Statciuk 2021-10-17 00:05:34 +03:00 committed by GitHub
commit ce2d8366f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

11
package-lock.json generated
View file

@ -22,6 +22,7 @@
"parse-duration": "^1.0.0",
"srcset": "^4.0.0",
"tabletojson": "^2.0.7",
"wildcard-match": "^5.1.2",
"xml-js": "^1.6.11"
}
},
@ -1605,6 +1606,11 @@
"node": ">=10"
}
},
"node_modules/wildcard-match": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/wildcard-match/-/wildcard-match-5.1.2.tgz",
"integrity": "sha512-qNXwI591Z88c8bWxp+yjV60Ch4F8Riawe3iGxbzquhy8Xs9m+0+SLFBGb/0yCTIDElawtaImC37fYZ+dr32KqQ=="
},
"node_modules/word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
@ -2874,6 +2880,11 @@
"webidl-conversions": "^6.1.0"
}
},
"wildcard-match": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/wildcard-match/-/wildcard-match-5.1.2.tgz",
"integrity": "sha512-qNXwI591Z88c8bWxp+yjV60Ch4F8Riawe3iGxbzquhy8Xs9m+0+SLFBGb/0yCTIDElawtaImC37fYZ+dr32KqQ=="
},
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",

View file

@ -22,6 +22,7 @@
"parse-duration": "^1.0.0",
"srcset": "^4.0.0",
"tabletojson": "^2.0.7",
"wildcard-match": "^5.1.2",
"xml-js": "^1.6.11"
}
}

View file

@ -1,16 +1,17 @@
const glob = require('glob')
const fs = require('fs')
const path = require('path')
const wcmatch = require('wildcard-match')
function list(pattern, include = [], exclude = []) {
return new Promise(resolve => {
glob(pattern, function (err, files) {
if (include.length) {
files = files.filter(filename => include.includes(filename))
files = files.filter(filename => include.some(item => wcmatch(item)(filename)))
}
if (exclude.length) {
files = files.filter(filename => !exclude.includes(filename))
files = files.filter(filename => !exclude.some(item => wcmatch(item)(filename)))
}
resolve(files)