11import * as fs from 'fs-extra' ;
22import { getUserHomeDir } from '../../../common/utils/pathUtils' ;
33import { isWindows } from '../../../common/utils/platformUtils' ;
4+ import { ShellStartupProvider } from './startupProvider' ;
5+ import { EnvironmentVariableScope , GlobalEnvironmentVariableCollection } from 'vscode' ;
6+ import { EnvironmentManagers } from '../../../internal.api' ;
47
58const pwshActivationEnvVarKey = 'VSCODE_PWSH_ACTIVATE' ;
69
@@ -74,7 +77,7 @@ async function getPowerShellProfile(): Promise<PowerShellProfile | undefined> {
7477 return existingProfiles . length > 0 ? existingProfiles . sort ( ( a , b ) => a . type - b . type ) [ 0 ] : undefined ;
7578}
7679
77- export async function isPowerShellStartupSetup ( ) : Promise < boolean > {
80+ async function isPowerShellStartupSetup ( ) : Promise < boolean > {
7881 const profile = await getPowerShellProfile ( ) ;
7982 if ( profile ) {
8083 const content = await fs . readFile ( profile . path , 'utf8' ) ;
@@ -83,7 +86,7 @@ export async function isPowerShellStartupSetup(): Promise<boolean> {
8386 return false ;
8487}
8588
86- export async function setupPowerShellStartup ( ) : Promise < void > {
89+ async function setupPowerShellStartup ( ) : Promise < void > {
8790 const lineSep = isWindows ( ) ? '\r\n' : '\n' ;
8891 const activationContent = `${ lineSep } ${ lineSep } # VSCODE-PYTHON-ACTIVATION:START${ lineSep } if ($env:${ pwshActivationEnvVarKey } -ne $null) {${ lineSep } Invoke-Expression $env:${ pwshActivationEnvVarKey } ${ lineSep } }${ lineSep } # VSCODE-PYTHON-ACTIVATION:END${ lineSep } ` ;
8992 const profile = await getPowerShellProfile ( ) ;
@@ -95,7 +98,7 @@ export async function setupPowerShellStartup(): Promise<void> {
9598 }
9699}
97100
98- export async function removePowerShellStartup ( ) : Promise < void > {
101+ async function removePowerShellStartup ( ) : Promise < void > {
99102 const profile = await getPowerShellProfile ( ) ;
100103 if ( profile ) {
101104 const content = await fs . readFile ( profile . path , 'utf8' ) ;
@@ -108,3 +111,30 @@ export async function removePowerShellStartup(): Promise<void> {
108111 }
109112 }
110113}
114+
115+ export class PowershellStartupProvider implements ShellStartupProvider {
116+ constructor ( private readonly em : EnvironmentManagers ) { }
117+ async isSetup ( ) : Promise < boolean > {
118+ return await isPowerShellStartupSetup ( ) ;
119+ }
120+
121+ async setupScripts ( ) : Promise < void > {
122+ await setupPowerShellStartup ( ) ;
123+ }
124+
125+ async teardownScripts ( ) : Promise < void > {
126+ await removePowerShellStartup ( ) ;
127+ }
128+
129+ async updateEnvVariables (
130+ global : GlobalEnvironmentVariableCollection ,
131+ scope : EnvironmentVariableScope ,
132+ ) : Promise < void > {
133+ const envVars = global . getScoped ( scope ) ;
134+ }
135+
136+ async removeEnvVariables ( envCollection : GlobalEnvironmentVariableCollection ) : Promise < void > {
137+ // Implementation for removing environment variables if needed
138+ // Currently, this method is not implemented
139+ }
140+ }
0 commit comments