mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-11 09:11:13 +00:00
fix(ui): make locale generation formatter-stable
This commit is contained in:
@@ -513,6 +513,7 @@ async function resolvePiCommand(): Promise<PiCommand> {
|
||||
|
||||
type RunProcessOptions = {
|
||||
cwd?: string;
|
||||
input?: string;
|
||||
rejectOnFailure?: boolean;
|
||||
};
|
||||
|
||||
@@ -525,7 +526,7 @@ async function runProcess(
|
||||
const child = spawn(executable, args, {
|
||||
cwd: options.cwd ?? ROOT,
|
||||
env: process.env,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
let stdout = "";
|
||||
@@ -537,6 +538,11 @@ async function runProcess(
|
||||
stderr += String(chunk);
|
||||
});
|
||||
child.once("error", reject);
|
||||
if (options.input !== undefined) {
|
||||
child.stdin.end(options.input);
|
||||
} else {
|
||||
child.stdin.end();
|
||||
}
|
||||
child.once("close", (code) => {
|
||||
if ((code ?? 1) !== 0 && options.rejectOnFailure) {
|
||||
reject(
|
||||
@@ -549,6 +555,18 @@ async function runProcess(
|
||||
});
|
||||
}
|
||||
|
||||
async function formatGeneratedTypeScript(filePath: string, source: string): Promise<string> {
|
||||
const result = await runProcess(
|
||||
"pnpm",
|
||||
["exec", "oxfmt", "--stdin-filepath", path.relative(ROOT, filePath)],
|
||||
{
|
||||
input: source,
|
||||
rejectOnFailure: true,
|
||||
},
|
||||
);
|
||||
return result.stdout;
|
||||
}
|
||||
|
||||
type PendingPrompt = {
|
||||
id: string;
|
||||
reject: (reason?: unknown) => void;
|
||||
@@ -956,7 +974,10 @@ async function syncLocale(
|
||||
workflow: CONTROL_UI_I18N_WORKFLOW,
|
||||
};
|
||||
|
||||
const expectedLocale = renderLocaleModule(entry, nextMap);
|
||||
const expectedLocale = await formatGeneratedTypeScript(
|
||||
existingPath,
|
||||
renderLocaleModule(entry, nextMap),
|
||||
);
|
||||
const expectedMeta = renderMeta(nextMeta);
|
||||
const expectedGlossary = renderGlossary(glossary.length === 0 ? DEFAULT_GLOSSARY : glossary);
|
||||
const expectedTm = renderTranslationMemory(tm);
|
||||
|
||||
Reference in New Issue
Block a user