sync local pi changes

This commit is contained in:
alex wiesner
2026-04-09 23:14:57 +01:00
parent 18245c778e
commit ec378ebd28
128 changed files with 22510 additions and 3436 deletions

View File

@@ -0,0 +1,33 @@
import type { FormatterConfig } from "../schema.ts";
export function createCommandFormatterRunner(deps: {
execCommand: (
command: string,
args: string[],
options: { cwd: string; timeout?: number },
) => Promise<{ code: number; stdout: string; stderr: string }>;
}) {
return {
async formatFile(input: {
absolutePath: string;
workspaceRoot: string;
formatter: FormatterConfig;
timeoutMs?: number;
}) {
const [command, ...args] = input.formatter.command.map((part) => part.replaceAll("{file}", input.absolutePath));
const result = await deps.execCommand(command, args, {
cwd: input.workspaceRoot,
timeout: input.timeoutMs,
});
if (result.code !== 0) {
return {
status: "failed" as const,
message: (result.stderr || result.stdout || `formatter exited with ${result.code}`).trim(),
};
}
return { status: "formatted" as const };
},
};
}