mirror of
https://github.com/iptv-org/epg
synced 2025-12-17 10:56:57 -05:00
Create file.js
This commit is contained in:
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user