fix(workflow): return script JSON reports and honor output options
This commit is contained in:
1 parent
fac81b08e8
commit
4c4cd42edd
4 files changed
+51
-16
No files matched your search
@@ -20,7 +20,7 @@ export async function handleWorkflowLintScript(
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
const isJson = booleanOption(parsed.options, ["json"]);
|
||||
const isJson = runtime.jsonMode || booleanOption(parsed.options, ["json", "j"]);
|
||||
const filePath = stringOption(parsed.options, ["file", "path"]);
|
||||
const codeInline = stringOption(parsed.options, ["code"]);
|
||||
const explicitType = (stringOption(parsed.options, ["type"]) || "code-js2").toLowerCase();
|
||||
@@ -68,8 +68,7 @@ export async function handleWorkflowLintScript(
|
||||
};
|
||||
|
||||
if (isJson) {
|
||||
printJson(report);
|
||||
return { stdout: "", stderr: "", exitCode: hasErrors ? 1 : 0 };
|
||||
return { stdout: printJson(report, runtime.outputOptions), stderr: "", exitCode: hasErrors ? 1 : 0 };
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
@@ -132,8 +131,7 @@ export async function handleWorkflowLintScript(
|
||||
const report = lintWorkflowScripts(workflow, targetNode);
|
||||
|
||||
if (isJson) {
|
||||
printJson(report);
|
||||
return { stdout: "", stderr: "", exitCode: report.allValid ? 0 : 1 };
|
||||
return { stdout: printJson(report, runtime.outputOptions), stderr: "", exitCode: report.allValid ? 0 : 1 };
|
||||
}
|
||||
|
||||
const lines: string[] = [];
|
||||
@@ -193,7 +191,7 @@ export async function handleWorkflowEvalScript(
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
const isJson = booleanOption(parsed.options, ["json"]);
|
||||
const isJson = runtime.jsonMode || booleanOption(parsed.options, ["json", "j"]);
|
||||
const filePath = stringOption(parsed.options, ["file", "path"]);
|
||||
const codeInline = stringOption(parsed.options, ["code"]);
|
||||
const timeoutStr = stringOption(parsed.options, ["timeout"]);
|
||||
@@ -250,8 +248,7 @@ export async function handleWorkflowEvalScript(
|
||||
const evalResult = await executeJavaScriptSandbox(code, inputs, { timeoutMs });
|
||||
|
||||
if (isJson) {
|
||||
printJson(evalResult);
|
||||
return { stdout: "", stderr: "", exitCode: evalResult.success ? 0 : 1 };
|
||||
return { stdout: printJson(evalResult, runtime.outputOptions), stderr: "", exitCode: evalResult.success ? 0 : 1 };
|
||||
}
|
||||
|
||||
return formatEvalCliResult(evalResult, filePath ? `file: ${filePath}` : "inline-code");
|
||||
@@ -358,8 +355,7 @@ export async function handleWorkflowEvalScript(
|
||||
const evalResult = await executeJavaScriptSandbox(code, inputs, { timeoutMs });
|
||||
|
||||
if (isJson) {
|
||||
printJson(evalResult);
|
||||
return { stdout: "", stderr: "", exitCode: evalResult.success ? 0 : 1 };
|
||||
return { stdout: printJson(evalResult, runtime.outputOptions), stderr: "", exitCode: evalResult.success ? 0 : 1 };
|
||||
}
|
||||
|
||||
const targetDesc = `节点 [${task.name}] ${task.label || task.displayName || ""} (${pipelineId})`;
|
||||
|
||||
Reference in new issue
Block a user