mirror of
https://github.com/iptv-org/epg
synced 2025-12-18 11:27:06 -05:00
Update file.js
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user