mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create file.js
This commit is contained in:
parent
d97b53970e
commit
4407cd2380
1 changed files with 23 additions and 0 deletions
23
scripts/file.js
Normal file
23
scripts/file.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
const glob = require('glob')
|
||||||
|
|
||||||
|
function list(include = [], exclude = []) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
glob('channels/**/*.xml', function (err, files) {
|
||||||
|
if (include.length) {
|
||||||
|
include = include.map(filename => `channels/${filename}.xml`)
|
||||||
|
files = files.filter(filename => include.includes(filename))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exclude.length) {
|
||||||
|
exclude = exclude.map(filename => `channels/${filename}.xml`)
|
||||||
|
files = files.filter(filename => !exclude.includes(filename))
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(files)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
list
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue