카드 손패 생성기: 기존 파일 줄바꿈(CRLF) 보존
This commit is contained in:
@@ -231,17 +231,20 @@ if (txt.includes('/ui/DefaultGroup/CardHand')) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const matches = txt.match(/\n {4}\]/g); // Entities 닫는 대괄호(4-space indent)는 파일 내 유일
|
const eol = txt.includes('\r\n') ? '\r\n' : '\n'; // 기존 파일의 줄바꿈 보존
|
||||||
if (!matches || matches.length !== 1) {
|
const splicePoint = `${eol} ]`; // Entities 닫는 대괄호(4-space indent)
|
||||||
console.error(`Expected exactly one Entities closing bracket, found ${matches ? matches.length : 0}. Aborting.`);
|
|
||||||
|
const count = txt.split(splicePoint).length - 1;
|
||||||
|
if (count !== 1) {
|
||||||
|
console.error(`Expected exactly one Entities closing bracket, found ${count}. Aborting.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const blocks = ents
|
const blocks = ents
|
||||||
.map((e) => JSON.stringify(e, null, 2).split('\n').map((l) => ' ' + l).join('\n'))
|
.map((e) => JSON.stringify(e, null, 2).split('\n').map((l) => ' ' + l).join(eol))
|
||||||
.join(',\n');
|
.join(',' + eol);
|
||||||
|
|
||||||
txt = txt.replace('\n ]', ',\n' + blocks + '\n ]');
|
txt = txt.replace(splicePoint, ',' + eol + blocks + eol + ' ]');
|
||||||
|
|
||||||
JSON.parse(txt); // 유효성 검증 (실패 시 throw)
|
JSON.parse(txt); // 유효성 검증 (실패 시 throw)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user