From 937dee050dd12fd338c7bfeed251e838acb5f56b Mon Sep 17 00:00:00 2001 From: akanyan Date: Thu, 30 May 2024 19:13:20 +0900 Subject: [PATCH] fix: make the output *actually* crlf --- index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index f1d1795..8b2fdda 100644 --- a/index.ts +++ b/index.ts @@ -9,18 +9,19 @@ const readChart = async (fname: string) => { let res: string[] = []; let isBPalette = false; let isCorrectVersion = false; - for(const line of data) { + for(let line of data) { + line = line.trimEnd(); if(line.startsWith('VERSION')) { - if(line.trim() === 'VERSION\t1\t6\t0') { - res.push('VERSION\t1\t7\t0\r\n'); + if(line === 'VERSION\t1\t6\t0') { + res.push('VERSION\t1\t7\t0'); isCorrectVersion = true; } } else if(line.startsWith('[')) { - isBPalette = line.trim() === '[B_PALETTE]'; + isBPalette = line === '[B_PALETTE]'; res.push(line); } else if(isBPalette) { - if(line.trim().length > 0) { - res.push(`${line.trim()}\t0\r\n`); + if(line.length > 0) { + res.push(`${line}\t0`); } else { res.push(line); } @@ -33,7 +34,7 @@ const readChart = async (fname: string) => { console.log(`Skipped ${fname}`); } else { g_count += 1; - await fs.writeFile(fname, res); + await fs.writeFile(fname, res.join('\r\n')); console.log(`Updated ${fname}`); } }