Skip to content

Commit 837904c

Browse files
committed
chore: use ShellConstants for shell name
1 parent 2f340ad commit 837904c

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/features/terminal/runInTerminal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { onDidEndTerminalShellExecution } from '../../common/window.apis';
44
import { createDeferred } from '../../common/utils/deferred';
55
import { quoteArgs } from '../execution/execUtils';
66
import { identifyTerminalShell } from '../common/shellDetector';
7+
import { ShellConstants } from '../common/shellConstants';
78

89
export async function runInTerminal(
910
environment: PythonEnvironment,
@@ -33,7 +34,7 @@ export async function runInTerminal(
3334
} else {
3435
const shellType = identifyTerminalShell(terminal);
3536
let text = quoteArgs([executable, ...allArgs]).join(' ');
36-
if (shellType === 'pwsh' && !text.startsWith('&')) {
37+
if (shellType === ShellConstants.PWSH && !text.startsWith('&')) {
3738
// PowerShell requires commands to be prefixed with '&' to run them.
3839
text = `& ${text}`;
3940
}

src/features/terminal/shells/bash/bashEnvs.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import { getCommandAsString } from '../utils';
88
import { BASH_ENV_KEY, ZSH_ENV_KEY } from './bashConstants';
99

1010
export class BashEnvsProvider implements ShellEnvsProvider {
11-
constructor(public readonly shell: 'bash' | 'gitbash') {}
11+
constructor(public readonly shellType: 'bash' | 'gitbash') {}
1212

1313
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
1414
try {
15-
const bashActivation = getActivationCommandForShell(env, this.shell);
15+
const bashActivation = getActivationCommandForShell(env, this.shellType);
1616
if (bashActivation) {
1717
const command = getCommandAsString(bashActivation, '&&');
1818
collection.replace(BASH_ENV_KEY, command);
1919
} else {
2020
collection.delete(BASH_ENV_KEY);
2121
}
2222
} catch (err) {
23-
traceError(`Failed to update env variables for ${this.shell}`, err);
23+
traceError(`Failed to update env variables for ${this.shellType}`, err);
2424
collection.delete(BASH_ENV_KEY);
2525
}
2626
}
@@ -42,13 +42,14 @@ export class BashEnvsProvider implements ShellEnvsProvider {
4242
}
4343
return undefined;
4444
} catch (err) {
45-
traceError(`Failed to get env variables for ${this.shell}`, err);
45+
traceError(`Failed to get env variables for ${this.shellType}`, err);
4646
return undefined;
4747
}
4848
}
4949
}
5050

5151
export class ZshEnvsProvider implements ShellEnvsProvider {
52+
public readonly shellType: string = ShellConstants.ZSH;
5253
async updateEnvVariables(envVars: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
5354
try {
5455
const zshActivation = getActivationCommandForShell(env, ShellConstants.ZSH);

src/features/terminal/shells/pwsh/pwshEnvs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { ShellConstants } from '../../../common/shellConstants';
88
import { POWERSHELL_ENV_KEY } from './pwshConstants';
99

1010
export class PowerShellEnvsProvider implements ShellEnvsProvider {
11+
public readonly shellType: string = ShellConstants.PWSH;
12+
1113
async updateEnvVariables(collection: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void> {
1214
try {
1315
const pwshActivation = getActivationCommandForShell(env, ShellConstants.PWSH);

src/features/terminal/shells/startupProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ShellStartupScriptProvider {
2121
}
2222

2323
export interface ShellEnvsProvider {
24+
readonly shellType: string;
2425
updateEnvVariables(envVars: EnvironmentVariableCollection, env: PythonEnvironment): Promise<void>;
2526
removeEnvVariables(envVars: EnvironmentVariableCollection): Promise<void>;
2627
getEnvVariables(env?: PythonEnvironment): Promise<Map<string, string | undefined> | undefined>;

0 commit comments

Comments
 (0)