fix(ci): use Windows-safe formatter spawn

This commit is contained in:
Peter Steinberger
2026-03-22 23:23:52 +00:00
parent 63130118ba
commit 60273758f8
2 changed files with 10 additions and 3 deletions

View File

@@ -19,17 +19,22 @@ function readIfExists(filePath: string): string | null {
function formatTypeScriptModule(source: string, outputPath: string): string {
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const formatter = spawnSync(
process.platform === "win32" ? "pnpm.cmd" : "pnpm",
process.platform === "win32" ? "pnpm" : "pnpm",
["exec", "oxfmt", "--stdin-filepath", outputPath],
{
cwd: repoRoot,
input: source,
encoding: "utf8",
// Windows requires a shell to launch package-manager shim scripts reliably.
...(process.platform === "win32" ? { shell: true } : {}),
},
);
if (formatter.status !== 0) {
const details =
formatter.stderr?.trim() || formatter.stdout?.trim() || "unknown formatter failure";
formatter.stderr?.trim() ||
formatter.stdout?.trim() ||
formatter.error?.message ||
"unknown formatter failure";
throw new Error(`failed to format generated base config schema: ${details}`);
}
return formatter.stdout;

View File

@@ -129,12 +129,14 @@ function normalizePluginManifest(raw) {
function formatTypeScriptModule(source, { outputPath }) {
const formatterPath = path.relative(FORMATTER_CWD, outputPath) || outputPath;
const formatter = spawnSync(
process.platform === "win32" ? "pnpm.cmd" : "pnpm",
process.platform === "win32" ? "pnpm" : "pnpm",
["exec", "oxfmt", "--stdin-filepath", formatterPath],
{
cwd: FORMATTER_CWD,
input: source,
encoding: "utf8",
// Windows requires a shell to launch package-manager shim scripts reliably.
...(process.platform === "win32" ? { shell: true } : {}),
},
);
if (formatter.status !== 0) {