feat: auto-strip UTF-8 BOM when reading local files in CLI (#8911)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-04-22 15:50:47 +00:00
committed by GitHub
co-authored by Claude Opus 4.5
parent dc896737ac
commit 99bc96d0b2
22 changed files with 204 additions and 87 deletions
+4 -3
View File
@@ -1,5 +1,6 @@
import { execFileSync } from "node:child_process";
import { readFile, stat } from "node:fs/promises";
import { stat } from "node:fs/promises";
import { readTextFile } from "./utils.ts";
import type { SyncCodebase } from "./codebase.ts";
import { parseMetadataFileIfExists } from "./metadata.ts";
import { inferContentTypeFromFilePath } from "./script_common.ts";
@@ -16,7 +17,7 @@ export class UnsupportedLocalPathScriptPreviewError extends Error {
async function readOptionalLock(scriptPath: string): Promise<string | undefined> {
try {
return await readFile(scriptPath + ".script.lock", "utf-8");
return await readTextFile(scriptPath + ".script.lock");
} catch {
return undefined;
}
@@ -138,7 +139,7 @@ export async function resolvePreviewLocalScriptState(
return {
filePath,
content: await readFile(filePath, "utf-8"),
content: await readTextFile(filePath),
language,
lock: normalizeOptionalLock(rawLock),
tag: metadata?.payload?.tag,