mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
refactor(cli): reuse owned result writes (#16573)
This commit is contained in:
1 parent
c8bcb4ef8e
commit
24ca2cbbe5
1 file changed
+16
-30
+16
-30
@@ -646,9 +646,8 @@ export const createCliResultOutput = (
|
||||
!options.tokenCount &&
|
||||
format !== "json" &&
|
||||
format !== "jsonl";
|
||||
if (format === "jsonl") {
|
||||
handled = true;
|
||||
try {
|
||||
if (format === "jsonl")
|
||||
return writeOwnedOutput(async () => {
|
||||
error = await writeCliJsonLines(
|
||||
{
|
||||
...options,
|
||||
@@ -664,12 +663,7 @@ export const createCliResultOutput = (
|
||||
},
|
||||
destination,
|
||||
);
|
||||
} catch (cause: unknown) {
|
||||
failed = true;
|
||||
throw cause;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
const meta = resultMeta(metadata);
|
||||
const errorDocument = envelopeFailed
|
||||
? fullFailureEnvelope(
|
||||
@@ -802,27 +796,19 @@ export const createCliResultOutput = (
|
||||
operationFailure === undefined
|
||||
)
|
||||
return false;
|
||||
handled = true;
|
||||
try {
|
||||
if (formattedText !== undefined) {
|
||||
// Retain the complete owned projection at the output boundary.
|
||||
await writeOutputText(destination, `${formattedText}\n`);
|
||||
} else {
|
||||
await writeJsonOutput(
|
||||
error === undefined
|
||||
? document
|
||||
: options.fullOutput
|
||||
? { ok: false, error, meta }
|
||||
: error,
|
||||
destination,
|
||||
format as "json" | "jsonl",
|
||||
);
|
||||
}
|
||||
} catch (cause: unknown) {
|
||||
failed = true;
|
||||
throw cause;
|
||||
}
|
||||
return true;
|
||||
return writeOwnedOutput(() =>
|
||||
formattedText !== undefined
|
||||
? writeOutputText(destination, `${formattedText}\n`)
|
||||
: writeJsonOutput(
|
||||
error === undefined
|
||||
? document
|
||||
: options.fullOutput
|
||||
? { ok: false, error, meta }
|
||||
: error,
|
||||
destination,
|
||||
format as "json" | "jsonl",
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user