mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create create-matrix.js
This commit is contained in:
parent
a86ae98210
commit
659b85a76d
1 changed files with 27 additions and 0 deletions
27
scripts/create-matrix.js
Normal file
27
scripts/create-matrix.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const glob = require('glob')
|
||||||
|
|
||||||
|
fileList(['ad'], []).then(files => {
|
||||||
|
const country = files.map(file => file.replace(/channels\/|\.xml/gi, ''))
|
||||||
|
const days = country.map(() => 2)
|
||||||
|
const matrix = { country, days }
|
||||||
|
const output = `::set-output name=matrix::${JSON.stringify(matrix)}`
|
||||||
|
console.log(output)
|
||||||
|
})
|
||||||
|
|
||||||
|
function fileList(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)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue