From 3b2e6afbcfca9d91aefc2e64d93cbc6405463cdd Mon Sep 17 00:00:00 2001 From: gahusb Date: Sat, 6 Jun 2026 01:42:20 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EC=86=90=ED=8C=A8=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EA=B8=B0:=20=EA=B8=B0=EC=A1=B4=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=A4=84=EB=B0=94=EA=BF=88(CRLF)=20=EB=B3=B4?= =?UTF-8?q?=EC=A1=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/gen-cardhand.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/gen-cardhand.mjs b/tools/gen-cardhand.mjs index 1653e88..e63652b 100644 --- a/tools/gen-cardhand.mjs +++ b/tools/gen-cardhand.mjs @@ -231,17 +231,20 @@ if (txt.includes('/ui/DefaultGroup/CardHand')) { process.exit(0); } -const matches = txt.match(/\n {4}\]/g); // Entities 닫는 대괄호(4-space indent)는 파일 내 유일 -if (!matches || matches.length !== 1) { - console.error(`Expected exactly one Entities closing bracket, found ${matches ? matches.length : 0}. Aborting.`); +const eol = txt.includes('\r\n') ? '\r\n' : '\n'; // 기존 파일의 줄바꿈 보존 +const splicePoint = `${eol} ]`; // Entities 닫는 대괄호(4-space indent) + +const count = txt.split(splicePoint).length - 1; +if (count !== 1) { + console.error(`Expected exactly one Entities closing bracket, found ${count}. Aborting.`); process.exit(1); } const blocks = ents - .map((e) => JSON.stringify(e, null, 2).split('\n').map((l) => ' ' + l).join('\n')) - .join(',\n'); + .map((e) => JSON.stringify(e, null, 2).split('\n').map((l) => ' ' + l).join(eol)) + .join(',' + eol); -txt = txt.replace('\n ]', ',\n' + blocks + '\n ]'); +txt = txt.replace(splicePoint, ',' + eol + blocks + eol + ' ]'); JSON.parse(txt); // 유효성 검증 (실패 시 throw)