mirror of
https://github.com/iptv-org/database.git
synced 2024-12-26 01:04:35 -05:00
Update validate.js
This commit is contained in:
parent
801905c081
commit
ef2bbd78e7
1 changed files with 14 additions and 1 deletions
|
@ -21,7 +21,20 @@ async function main() {
|
|||
]
|
||||
for (const filepath of files) {
|
||||
if (!filepath.endsWith('.csv')) continue
|
||||
const data = await csv.load(filepath).catch(err => {
|
||||
|
||||
const eol = await file.eol(filepath)
|
||||
if (eol !== 'CRLF') {
|
||||
logger.error(chalk.red(`\nError: file must have line endings with CRLF (${filepath})`))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const csvString = await file.read(filepath)
|
||||
if (/\s+$/.test(csvString)) {
|
||||
logger.error(chalk.red(`\nError: empty lines at the end of file not allowed (${filepath})`))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const data = await csv.fromString(csvString).catch(err => {
|
||||
logger.error(chalk.red(`\n${err.message} (${filepath})`))
|
||||
process.exit(1)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue