From 53ea3f7865900e243c8e0b4fa371c796f84475a5 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Wed, 15 Mar 2023 08:21:26 -0400 Subject: [PATCH] Remove unnecessary logging of stderr Signed-off-by: Timothy Johnson --- .../utilities/__tests__/ProcessUtils.test.ts | 21 +------------------ packages/utilities/src/ProcessUtils.ts | 8 ------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/packages/utilities/__tests__/ProcessUtils.test.ts b/packages/utilities/__tests__/ProcessUtils.test.ts index 4bbc0d51e..da8f66d44 100644 --- a/packages/utilities/__tests__/ProcessUtils.test.ts +++ b/packages/utilities/__tests__/ProcessUtils.test.ts @@ -10,7 +10,7 @@ */ import * as childProcess from "child_process"; -import { DaemonRequest, GuiResult, ImperativeConfig, ProcessUtils } from "../../utilities"; +import { GuiResult, ImperativeConfig, ProcessUtils } from "../../utilities"; jest.mock("child_process"); jest.mock("opener"); @@ -343,24 +343,5 @@ describe("ProcessUtils tests", () => { expect(childProcess.spawnSync).toHaveBeenCalledWith("cat", [filename], undefined); expect(caughtError.message).toBe(`Command failed: cat ${filename}\n${stderrBuffer.toString()}`); }); - - it("logs stderr output to daemon stream", () => { - const stderrBuffer = Buffer.from("Task failed successfully\n"); - const streamWriteMock = jest.fn(); - jest.spyOn(childProcess, "spawnSync").mockReturnValueOnce({ - status: 0, - stderr: stderrBuffer - } as any); - jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValueOnce({ - daemonContext: { - stream: { write: streamWriteMock } - } - } as any); - ProcessUtils.execAndCheckOutput("fail"); - expect(childProcess.spawnSync).toHaveBeenCalledWith("fail", undefined, undefined); - expect(streamWriteMock).toHaveBeenCalledWith(JSON.stringify({ - stderr: stderrBuffer.toString() - }) + DaemonRequest.EOW_DELIMITER); - }); }); }); diff --git a/packages/utilities/src/ProcessUtils.ts b/packages/utilities/src/ProcessUtils.ts index f6252b488..dda891419 100644 --- a/packages/utilities/src/ProcessUtils.ts +++ b/packages/utilities/src/ProcessUtils.ts @@ -156,14 +156,6 @@ export class ProcessUtils { // Implementation based on the child_process module // https://github.com/nodejs/node/blob/main/lib/child_process.js const result = spawnSync(command, args, options); - if (options?.stdio == null && result.stderr?.length > 0) { - const daemonStream = ImperativeConfig.instance.daemonContext?.stream; - if (daemonStream != null) { - daemonStream.write(DaemonRequest.create({ stderr: result.stderr.toString() })); - } else { - process.stderr.write(result.stderr); - } - } if (result.error != null) { throw result.error; } else if (result.status !== 0) {