Skip to content

Commit 61fcf3a

Browse files
author
Kartik Raj
authored
Properly build deactivate commands for powershell (#22570)
For #20950
1 parent db6e15e commit 61fcf3a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/client/terminals/envCollectionActivation/deactivateService.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ITerminalManager } from '../../common/application/types';
88
import { pathExists } from '../../common/platform/fs-paths';
99
import { _SCRIPTS_DIR } from '../../common/process/internal/scripts/constants';
1010
import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors/baseShellDetector';
11-
import { TerminalShellType } from '../../common/terminal/types';
11+
import { ITerminalHelper, TerminalShellType } from '../../common/terminal/types';
1212
import { Resource } from '../../common/types';
1313
import { waitForCondition } from '../../common/utils/async';
1414
import { cache } from '../../common/utils/decorators';
@@ -37,6 +37,7 @@ export class TerminalDeactivateService implements ITerminalDeactivateService {
3737
constructor(
3838
@inject(ITerminalManager) private readonly terminalManager: ITerminalManager,
3939
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
40+
@inject(ITerminalHelper) private readonly terminalHelper: ITerminalHelper,
4041
) {}
4142

4243
@cache(-1, true)
@@ -58,7 +59,11 @@ export class TerminalDeactivateService implements ITerminalDeactivateService {
5859
globalInterpreters.length > 0 && globalInterpreters[0] ? globalInterpreters[0].path : 'python';
5960
const checkIfFileHasBeenCreated = () => pathExists(outputFile);
6061
const stopWatch = new StopWatch();
61-
terminal.sendText(`${interpreterPath} "${this.envVarScript}" "${outputFile}"`);
62+
const command = this.terminalHelper.buildCommandForTerminal(shellType, interpreterPath, [
63+
this.envVarScript,
64+
outputFile,
65+
]);
66+
terminal.sendText(command);
6267
await waitForCondition(checkIfFileHasBeenCreated, 30_000, `"${outputFile}" file not created`);
6368
traceVerbose(`Time taken to get env vars using terminal is ${stopWatch.elapsedTime}ms`);
6469
}

src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ suite('Terminal Environment Variable Collection Service', () => {
341341

342342
test('Also prepend deactivate script location if available', async () => {
343343
reset(terminalDeactivateService);
344-
when(terminalDeactivateService.initializeScriptParams(anything())).thenResolve();
344+
when(terminalDeactivateService.initializeScriptParams(anything())).thenReject(); // Verify we swallow errors from here
345345
when(terminalDeactivateService.getScriptLocation(anything(), anything())).thenResolve('scriptLocation');
346346
const processEnv = { PATH: 'hello/1/2/3' };
347347
reset(environmentActivationService);

0 commit comments

Comments
 (0)