Files
epg/scripts/create-matrix.js

32 lines
771 B
JavaScript
Raw Normal View History

2021-10-13 19:56:46 +03:00
const { Command } = require('commander')
2021-10-12 01:42:32 +03:00
const file = require('./file')
2021-10-13 19:56:46 +03:00
const program = new Command()
program
.option('--include <include>', 'List of files to include', parseList)
.option('--exclude <exclude>', 'List of files to exclude', parseList)
.parse(process.argv)
2021-10-12 01:42:32 +03:00
2021-10-13 19:56:46 +03:00
const options = program.opts()
2021-10-15 20:05:24 +03:00
file.list('sites/*/*.channels.xml', options.include, options.exclude).then(files => {
2021-10-13 19:56:46 +03:00
const matrix = {
guide: []
}
files.forEach(filename => {
2021-10-28 22:57:59 +03:00
const [_, site, country] = filename.match(/sites\/.*\/(.*)_(.*)\.channels\.xml/i)
matrix.guide.push({ site, country })
2021-10-13 01:27:03 +03:00
})
2021-10-13 19:56:46 +03:00
const output = `::set-output name=matrix::${JSON.stringify(matrix)}`
console.log(output)
})
function parseList(str) {
if (!str) return []
return str.split(',')
}