Update create-matrix.js

This commit is contained in:
Aleksandr Statciuk 2021-10-13 19:56:46 +03:00
parent 5bd84efe5d
commit 1d013713e6

View file

@ -1,27 +1,37 @@
const { Command } = require('commander')
const file = require('./file') const file = require('./file')
const parser = require('./parser') const parser = require('./parser')
file const program = new Command()
.list('sites/*.channels.xml', [ program
'sites/andorradifusio.ad.channels.xml', .option('--include <include>', 'List of files to include', parseList)
'sites/arianaafgtv.com.channels.xml' .option('--exclude <exclude>', 'List of files to exclude', parseList)
]) .parse(process.argv)
.then(files => {
const matrix = {
guide: []
}
files.forEach(filename => { const options = program.opts()
const channelsFile = file.read(filename)
const parsed = parser.parseChannels(channelsFile) file.list('sites/*.channels.xml', options.include, options.exclude).then(files => {
parsed.groups.forEach(group => { const matrix = {
matrix.guide.push({ guide: []
site: parsed.site, }
country: group.country.toLowerCase()
}) files.forEach(filename => {
const channelsFile = file.read(filename)
const parsed = parser.parseChannels(channelsFile)
parsed.groups.forEach(group => {
matrix.guide.push({
site: parsed.site,
country: group.country.toLowerCase()
}) })
}) })
const output = `::set-output name=matrix::${JSON.stringify(matrix)}`
console.log(output)
}) })
const output = `::set-output name=matrix::${JSON.stringify(matrix)}`
console.log(output)
})
function parseList(str) {
if (!str) return []
return str.split(',')
}