Skip to content

Commit

Permalink
Properly build comamnd for powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Nov 29, 2023
1 parent 5edcd12 commit a433b7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ITerminalManager } from '../../common/application/types';
import { pathExists } from '../../common/platform/fs-paths';
import { _SCRIPTS_DIR } from '../../common/process/internal/scripts/constants';
import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors/baseShellDetector';
import { TerminalShellType } from '../../common/terminal/types';
import { ITerminalHelper, TerminalShellType } from '../../common/terminal/types';
import { Resource } from '../../common/types';
import { waitForCondition } from '../../common/utils/async';
import { cache } from '../../common/utils/decorators';
Expand Down Expand Up @@ -37,6 +37,7 @@ export class TerminalDeactivateService implements ITerminalDeactivateService {
constructor(
@inject(ITerminalManager) private readonly terminalManager: ITerminalManager,
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
@inject(ITerminalHelper) private readonly terminalHelper: ITerminalHelper,
) {}

@cache(-1, true)
Expand All @@ -58,7 +59,11 @@ export class TerminalDeactivateService implements ITerminalDeactivateService {
globalInterpreters.length > 0 && globalInterpreters[0] ? globalInterpreters[0].path : 'python';
const checkIfFileHasBeenCreated = () => pathExists(outputFile);
const stopWatch = new StopWatch();
terminal.sendText(`${interpreterPath} "${this.envVarScript}" "${outputFile}"`);
const command = this.terminalHelper.buildCommandForTerminal(shellType, interpreterPath, [
this.envVarScript,
outputFile,
]);
terminal.sendText(command);
await waitForCondition(checkIfFileHasBeenCreated, 30_000, `"${outputFile}" file not created`);
traceVerbose(`Time taken to get env vars using terminal is ${stopWatch.elapsedTime}ms`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ShellIntegrationService implements IShellIntegrationService {
const deferred = createDeferred<void>();
const timestamp = new Date().getTime();
const name = `Python ${timestamp}`;
const onDidExecuteTerminalCommand = this.appShell.onDidExecuteTerminalCommand?.bind(this.appShell);
const { onDidExecuteTerminalCommand } = this.appShell;
if (!onDidExecuteTerminalCommand) {
// Proposed API is not available, assume shell integration is working at this point.
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ suite('Terminal Environment Variable Collection Service', () => {

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

0 comments on commit a433b7b

Please sign in to comment.