Skip to content

Commit

Permalink
chore: command executor posting to command stream
Browse files Browse the repository at this point in the history
  • Loading branch information
jgellin-sf committed Oct 25, 2024
1 parent a6f8463 commit 43ec575
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/salesforcedx-utils-vscode/src/cli/commandExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string, string>();
baseEnvironment.set('SFDX_ENV', 'test');
const options = { env: { TEST: 'test' } };
const patchedOptions = CliCommandExecutor.patchEnv(options, baseEnvironment);

Check failure on line 23 in packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts

View workflow job for this annotation

GitHub Actions / build-and-test / build-all / build-all

Property 'patchEnv' is protected and only accessible within class 'CliCommandExecutor' and its subclasses.

Check failure on line 23 in packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts

View workflow job for this annotation

GitHub Actions / build-and-test / unit-tests / linux-unit-tests / linux-unit-tests

Property 'patchEnv' is protected and only accessible within class 'CliCommandExecutor' and its subclasses.

Check failure on line 23 in packages/salesforcedx-utils-vscode/test/jest/cli/commandExecutor.test.ts

View workflow job for this annotation

GitHub Actions / build-and-test / unit-tests / windows-unit-tests / windows-unit-tests

Property 'patchEnv' is protected and only accessible within class 'CliCommandExecutor' and its subclasses.
expect(patchedOptions.env).toEqual({ SFDX_ENV: 'test', TEST: 'test', SFDX_TOOL: 'salesforce-vscode-extensions' });
});
});
});

0 comments on commit 43ec575

Please sign in to comment.