Update file.js

This commit is contained in:
Aleksandr Statciuk 2021-09-08 20:46:19 +03:00
parent 8a2473c64c
commit e51f10023a
1 changed files with 20 additions and 0 deletions

View File

@ -1,10 +1,30 @@
const markdownInclude = require('markdown-include')
const path = require('path')
const glob = require('glob')
const fs = require('fs')
const rootPath = path.resolve(__dirname) + '/../../'
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) {
return path.parse(filename).name
}