Skip to content

Commit ae58239

Browse files
committed
fix(scripts): route i18n formatter through pnpm runner
1 parent 1cd6f81 commit ae58239

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

scripts/control-ui-i18n.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ import * as ts from "typescript";
1010
import { formatErrorMessage } from "../src/infra/errors.ts";
1111
import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs";
1212

13+
const { formatGeneratedModule } = (await import(
14+
new URL("./lib/format-generated-module.mjs", import.meta.url).href
15+
)) as {
16+
formatGeneratedModule: (
17+
source: string,
18+
options: {
19+
errorLabel: string;
20+
outputPath: string;
21+
repoRoot: string;
22+
},
23+
) => string;
24+
};
25+
1326
interface TranslationMap {
1427
[key: string]: string | TranslationMap;
1528
}
@@ -1222,18 +1235,12 @@ export async function runProcess(
12221235
}
12231236

12241237
async function formatGeneratedTypeScript(filePath: string, source: string): Promise<string> {
1225-
const directFormatterPath = path.join(ROOT, "node_modules", ".bin", "oxfmt");
1226-
const formatterCommand =
1227-
process.platform !== "win32" && existsSync(directFormatterPath) ? directFormatterPath : "pnpm";
1228-
const formatterArgs =
1229-
formatterCommand === directFormatterPath
1230-
? ["--stdin-filepath", path.relative(ROOT, filePath)]
1231-
: ["exec", "oxfmt", "--stdin-filepath", path.relative(ROOT, filePath)];
1232-
const result = await runProcess(formatterCommand, formatterArgs, {
1233-
input: source,
1234-
rejectOnFailure: true,
1238+
const formatted = formatGeneratedModule(source, {
1239+
errorLabel: "control ui locale",
1240+
outputPath: filePath,
1241+
repoRoot: ROOT,
12351242
});
1236-
return restoreReplacementCorruptedStringLiterals(source, result.stdout);
1243+
return restoreReplacementCorruptedStringLiterals(source, formatted);
12371244
}
12381245

12391246
function restoreReplacementCorruptedStringLiterals(source: string, formatted: string): string {

0 commit comments

Comments
 (0)