Format the split tools' output with the tools checkout's oxfmt configuration

The split tools ran oxfmt in the checkout they rewrite. oxfmt looks up
its configuration from that directory and from the formatted files'
directories, and runs an oxfmt.config.ts it finds there, so a branch that
rehome-split rewrites could run code with the maintainer's permissions.
The tools now format through format.mjs, which passes the tools
checkout's .oxfmtrc.jsonc with --config and disables the nested lookup,
so no configuration file of the rewritten checkout is read or run. With
no files to format it does nothing, where oxfmt would format the whole
directory.

The split-tools tests cover split-methods and move-state on a checkout
whose root and src directory commit an oxfmt.config.ts that records it
ran.
This commit is contained in:
Chris Tate
2026-10-22 11:12:02 -05:00
parent 76d7d29b13
commit 2b657e6e3c
7 changed files with 88 additions and 18 deletions
+2 -5
View File
@@ -39,8 +39,8 @@
import { readFileSync } from "node:fs";
import { dirname, join, relative, resolve, posix } from "node:path";
import { createRequire } from "node:module";
import { execFileSync } from "node:child_process";
import { confine, confineHost } from "./confine.mjs";
import { formatFiles } from "./format.mjs";
const [command, configPath, ...flags] = process.argv.slice(2);
const config = JSON.parse(readFileSync(configPath, "utf8"));
@@ -533,10 +533,7 @@ function apply() {
// Format what changed with the tools checkout's oxfmt, so the split and
// every rehome of it are formatted the same way.
const touched = [modulePath, ...[...files.keys()].map((f) => join(moduleDir, f))];
execFileSync(join(toolsDir, "node_modules/.bin/oxfmt"), touched, {
cwd: repo,
stdio: ["ignore", "ignore", "inherit"],
});
formatFiles(toolsDir, touched, { cwd: repo, stdio: ["ignore", "ignore", "inherit"] });
for (const [file, entry] of files) console.log(`${file}: ${entry.decls.length} declarations`);
}