Update file.js
This commit is contained in:
parent
8a2473c64c
commit
e51f10023a
|
@ -1,10 +1,30 @@
|
||||||
const markdownInclude = require('markdown-include')
|
const markdownInclude = require('markdown-include')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const glob = require('glob')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
const rootPath = path.resolve(__dirname) + '/../../'
|
const rootPath = path.resolve(__dirname) + '/../../'
|
||||||
const file = {}
|
const file = {}
|
||||||
|
|
||||||
|
file.list = function (include = [], exclude = []) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
glob('channels/*.m3u', function (err, files) {
|
||||||
|
console.log(include, exclude)
|
||||||
|
if (include.length) {
|
||||||
|
include = include.map(filename => `channels/${filename}.m3u`)
|
||||||
|
files = files.filter(filename => include.includes(filename))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exclude.length) {
|
||||||
|
exclude = exclude.map(filename => `channels/${filename}.m3u`)
|
||||||
|
files = files.filter(filename => !exclude.includes(filename))
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(files)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
file.getFilename = function (filename) {
|
file.getFilename = function (filename) {
|
||||||
return path.parse(filename).name
|
return path.parse(filename).name
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue