mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update file.js
This commit is contained in:
parent
e9d38de24c
commit
04bbec5e90
1 changed files with 3 additions and 2 deletions
|
@ -1,16 +1,17 @@
|
||||||
const glob = require('glob')
|
const glob = require('glob')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const wcmatch = require('wildcard-match')
|
||||||
|
|
||||||
function list(pattern, include = [], exclude = []) {
|
function list(pattern, include = [], exclude = []) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
glob(pattern, function (err, files) {
|
glob(pattern, function (err, files) {
|
||||||
if (include.length) {
|
if (include.length) {
|
||||||
files = files.filter(filename => include.includes(filename))
|
files = files.filter(filename => include.some(item => wcmatch(item)(filename)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exclude.length) {
|
if (exclude.length) {
|
||||||
files = files.filter(filename => !exclude.includes(filename))
|
files = files.filter(filename => !exclude.some(item => wcmatch(item)(filename)))
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(files)
|
resolve(files)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue