From 43ec57515fab996cf1dab0f695489aae99b7f587 Mon Sep 17 00:00:00 2001 From: Jon Gellin Date: Fri, 25 Oct 2024 12:11:26 -0400 Subject: [PATCH] chore: command executor posting to command stream --- .../src/cli/commandExecutor.ts | 4 --- .../test/jest/cli/commandExecutor.test.ts | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts diff --git a/packages/salesforcedx-utils-vscode/src/cli/commandExecutor.ts b/packages/salesforcedx-utils-vscode/src/cli/commandExecutor.ts index 1b252fefec..c2680fc721 100644 --- a/packages/salesforcedx-utils-vscode/src/cli/commandExecutor.ts +++ b/packages/salesforcedx-utils-vscode/src/cli/commandExecutor.ts @@ -174,18 +174,14 @@ export class CompositeCliCommandExecution implements CommandExecution { } public successfulExit() { - CommandEventStream.getInstance().post({ type: CommandEventType.EXIT_CODE, exitCode: 0 }); this.exitSubject.next(0); } public failureExit(e?: {}) { if (e) { - // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions - CommandEventStream.getInstance().post({ type: CommandEventType.ERROR, error: `${e}` }); // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions this.stderr.next(`${e}${os.EOL}`); } - CommandEventStream.getInstance().post({ type: CommandEventType.EXIT_CODE, exitCode: 1 }); this.exitSubject.next(1); } } diff --git a/packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts b/packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts new file mode 100644 index 0000000000..f5b22add93 --- /dev/null +++ b/packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ + +import { CliCommandExecutor } from "../../../src/cli/commandExecutor"; +import { CommandEventStream } from "../../../src/commands/commandEventStream"; + + +describe('CompositeCliCommandExecution', () => { + const commandEventStreamPostSpy = jest.spyOn(CommandEventStream.getInstance(), 'post'); + +}); + +describe('CliCommandExecutor', () => { + describe('patchEnv', () => { + it('should patch the environment with the base environment', () => { + const baseEnvironment = new Map(); + baseEnvironment.set('SFDX_ENV', 'test'); + const options = { env: { TEST: 'test' } }; + const patchedOptions = CliCommandExecutor.patchEnv(options, baseEnvironment); + expect(patchedOptions.env).toEqual({ SFDX_ENV: 'test', TEST: 'test', SFDX_TOOL: 'salesforce-vscode-extensions' }); + }); + }); +});