Update validate.js

This commit is contained in:
Aleksandr Statciuk 2022-04-09 03:44:51 +03:00
parent b893c10765
commit 6087a6c06a

View file

@ -53,6 +53,21 @@ async function main() {
}
fileErrors = fileErrors.concat(findDuplicatesById(data))
} else if (filename === 'blocklist') {
let channels = await csv.fromFile('data/channels.csv').catch(err => {
logger.error(chalk.red(`\nError: ${err.message}`))
process.exit(1)
})
channels = channels.map(c => c.id)
data.forEach((row, i) => {
if (channels.length && !channels.includes(row.channel)) {
fileErrors.push({
line: i + 2,
message: `"${row.channel}" is missing in the channels.csv`
})
}
})
}
const schema = Joi.object(schemes[filename])