@@ -10,6 +10,19 @@ import * as ts from "typescript";
1010import { formatErrorMessage } from "../src/infra/errors.ts" ;
1111import { 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+
1326interface TranslationMap {
1427 [ key : string ] : string | TranslationMap ;
1528}
@@ -1228,18 +1241,12 @@ export async function runProcess(
12281241}
12291242
12301243async function formatGeneratedTypeScript ( filePath : string , source : string ) : Promise < string > {
1231- const directFormatterPath = path . join ( ROOT , "node_modules" , ".bin" , "oxfmt" ) ;
1232- const formatterCommand =
1233- process . platform !== "win32" && existsSync ( directFormatterPath ) ? directFormatterPath : "pnpm" ;
1234- const formatterArgs =
1235- formatterCommand === directFormatterPath
1236- ? [ "--stdin-filepath" , path . relative ( ROOT , filePath ) ]
1237- : [ "exec" , "oxfmt" , "--stdin-filepath" , path . relative ( ROOT , filePath ) ] ;
1238- const result = await runProcess ( formatterCommand , formatterArgs , {
1239- input : source ,
1240- rejectOnFailure : true ,
1244+ const formatted = formatGeneratedModule ( source , {
1245+ errorLabel : "control ui locale" ,
1246+ outputPath : filePath ,
1247+ repoRoot : ROOT ,
12411248 } ) ;
1242- return restoreReplacementCorruptedStringLiterals ( source , result . stdout ) ;
1249+ return restoreReplacementCorruptedStringLiterals ( source , formatted ) ;
12431250}
12441251
12451252function restoreReplacementCorruptedStringLiterals ( source : string , formatted : string ) : string {
0 commit comments