From 9d30f9fcfabe12b8791035321e70503940a69867 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 10 Jun 2022 16:29:30 +0300 Subject: [PATCH] Update validate.js --- scripts/db/validate.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/db/validate.js b/scripts/db/validate.js index 7ff179fd..ae9359be 100644 --- a/scripts/db/validate.js +++ b/scripts/db/validate.js @@ -26,17 +26,17 @@ async function main() { for (let filepath of allFiles) { if (!filepath.endsWith('.csv')) continue - const eol = await file.eol(filepath) - if (eol !== 'CRLF') - return handleError(`Error: file must have line endings with CRLF (${filepath})`) - const csvString = await file.read(filepath) if (/\s+$/.test(csvString)) return handleError(`Error: empty lines at the end of file not allowed (${filepath})`) - const rows = csvString.split('\r\n') + const rows = csvString.split(/\r\n/) const headers = rows[0].split(',') for (let [i, line] of rows.entries()) { + if (line.indexOf('\n') > -1) + return handleError( + `Error: row ${i + 1} has the wrong line ending character, should be CRLF (${filepath})` + ) if (line.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/).length !== headers.length) return handleError(`Error: row ${i + 1} has the wrong number of columns (${filepath})`) }