




















@@ -647,6 +647,28 @@ const createRunNodeOutputTee = (deps) => {
647647if (!outputLogPath) {
648648return null;
649649}
650+try {
651+const existing = deps.fs.statSync(outputLogPath);
652+if (existing.isDirectory()) {
653+return {
654+ outputLogPath,
655+write() {},
656+async close() {
657+throw new Error(`output log path is a directory: ${outputLogPath}`);
658+},
659+};
660+}
661+} catch (error) {
662+if (error?.code && error.code !== "ENOENT") {
663+return {
664+ outputLogPath,
665+write() {},
666+async close() {
667+throw error;
668+},
669+};
670+}
671+}
650672deps.fs.mkdirSync(path.dirname(outputLogPath), { recursive: true });
651673const stream = deps.fs.createWriteStream(outputLogPath, {
652674flags: "a",
@@ -936,16 +958,18 @@ const runOpenClaw = async (deps) => {
936958return res.exitCode ?? 1;
937959};
938960939-const pipeSpawnedOutput = (childProcess, deps) => {
940-if (!shouldPipeSpawnedOutput(deps)) {
961+const pipeSpawnedOutput = (childProcess, deps, options = {}) => {
962+const stdoutTarget = options.stdoutTarget ?? "stdout";
963+if (!shouldPipeSpawnedOutput(deps) && stdoutTarget !== "stderr") {
941964return;
942965}
943966const stderrFilter =
944967deps.env[RUN_NODE_FILTER_SYNC_IO_STDERR_ENV] === "1"
945968 ? createSyncIoTraceStderrFilter(deps)
946969 : null;
947970childProcess.stdout?.on("data", (chunk) => {
948-writeRunnerStream(deps, deps.stdout, chunk);
971+const target = stdoutTarget === "stderr" ? deps.stderr : deps.stdout;
972+writeRunnerStream(deps, target, chunk);
949973deps.outputTee?.write(chunk);
950974});
951975childProcess.stderr?.on("data", (chunk) => {
@@ -1389,9 +1413,9 @@ export async function runNodeMain(params = {}) {
13891413const assetBuild = deps.spawn(buildCmd, bundledPluginAssetBuildArgs, {
13901414cwd: deps.cwd,
13911415env: deps.env,
1392-stdio: shouldPipeSpawnedOutput(deps) ? ["inherit", "pipe", "pipe"] : "inherit",
1416+stdio: ["inherit", "pipe", "pipe"],
13931417});
1394-pipeSpawnedOutput(assetBuild, deps);
1418+pipeSpawnedOutput(assetBuild, deps, { stdoutTarget: "stderr" });
13951419const assetBuildRes = await waitForSpawnedProcess(assetBuild, deps);
13961420const assetBuildInterruptedExitCode = getInterruptedSpawnExitCode(assetBuildRes);
13971421if (assetBuildInterruptedExitCode !== null) {
@@ -1407,9 +1431,9 @@ export async function runNodeMain(params = {}) {
14071431 ...deps.env,
14081432[RUN_NODE_SKIP_DTS_BUILD_ENV]: deps.env[RUN_NODE_SKIP_DTS_BUILD_ENV] ?? "1",
14091433},
1410-stdio: shouldPipeSpawnedOutput(deps) ? ["inherit", "pipe", "pipe"] : "inherit",
1434+stdio: ["inherit", "pipe", "pipe"],
14111435});
1412-pipeSpawnedOutput(build, deps);
1436+pipeSpawnedOutput(build, deps, { stdoutTarget: "stderr" });
1413143714141438const buildRes = await waitForSpawnedProcess(build, deps);
14151439const interruptedExitCode = getInterruptedSpawnExitCode(buildRes);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。