fix(ci): normalize line endings in bundled-defaults generator

On Windows, `git checkout` converts source files to CRLF via the
`* text=auto` policy. The generator inlined raw file content as JSON
strings, so the Windows regeneration produced `\r\n` escapes while the
committed artifact (written on Linux) used `\n`. `bun run check:bundled`
then flagged the file as stale and failed the Windows CI job.

Fix by normalizing CRLF → LF both when reading source defaults and when
comparing against the existing generated file. No-op on Linux.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Cole Medin 2026-04-16 17:55:24 -05:00
parent b7b445bd31
commit 75427c7cdd

View file

@ -79,7 +79,10 @@ async function collectFiles(dir: string, extensions: readonly string[]): Promise
);
}
seen.add(name);
const content = await readFile(join(dir, entry), 'utf-8');
const raw = await readFile(join(dir, entry), 'utf-8');
// Normalize to LF so output is identical regardless of the checkout's
// line-ending policy (e.g. Windows `core.autocrlf=true` yields CRLF).
const content = raw.replace(/\r\n/g, '\n');
if (!content.trim()) {
throw new Error(`Bundled default "${entry}" in ${dir} is empty.`);
}
@ -144,7 +147,10 @@ async function main(): Promise<void> {
if (CHECK_ONLY) {
let existing = '';
try {
existing = await readFile(OUTPUT_PATH, 'utf-8');
const raw = await readFile(OUTPUT_PATH, 'utf-8');
// Same LF normalization as collectFiles — the .ts itself may be
// checked out with CRLF line endings on Windows.
existing = raw.replace(/\r\n/g, '\n');
} catch (e) {
const err = e as NodeJS.ErrnoException;
if (err.code !== 'ENOENT') throw err;