@@ -6,18 +6,13 @@ import { traceError, traceInfo, traceVerbose } from '../../../../common/logging'
66import { ShellConstants } from '../../../common/shellConstants' ;
77import { hasStartupCode , insertStartupCode , removeStartupCode } from '../common/editUtils' ;
88import { ShellScriptEditState , ShellSetupState , ShellStartupScriptProvider } from '../startupProvider' ;
9- import { BASH_ENV_KEY , BASH_OLD_ENV_KEY , BASH_SCRIPT_VERSION , ZSH_ENV_KEY , ZSH_OLD_ENV_KEY } from './bashConstants' ;
9+ import { BASH_ENV_KEY , BASH_OLD_ENV_KEY , BASH_SCRIPT_VERSION } from './bashConstants' ;
1010
1111async function isBashLikeInstalled ( ) : Promise < boolean > {
1212 const result = await Promise . all ( [ which ( 'bash' , { nothrow : true } ) , which ( 'sh' , { nothrow : true } ) ] ) ;
1313 return result . some ( ( r ) => r !== null ) ;
1414}
1515
16- async function isZshInstalled ( ) : Promise < boolean > {
17- const result = await which ( 'zsh' , { nothrow : true } ) ;
18- return result !== null ;
19- }
20-
2116async function isGitBashInstalled ( ) : Promise < boolean > {
2217 const gitPath = await which ( 'git' , { nothrow : true } ) ;
2318 if ( gitPath ) {
@@ -34,14 +29,6 @@ async function getBashProfiles(): Promise<string> {
3429 return profile ;
3530}
3631
37- async function getZshProfiles ( ) : Promise < string > {
38- const zdotdir = process . env . ZDOTDIR ;
39- const baseDir = zdotdir || os . homedir ( ) ;
40- const profile : string = path . join ( baseDir , '.zshrc' ) ;
41-
42- return profile ;
43- }
44-
4532const regionStart = '# >>> vscode python' ;
4633const regionEnd = '# <<< vscode python' ;
4734
@@ -180,68 +167,6 @@ export class BashStartupProvider implements ShellStartupScriptProvider {
180167 }
181168}
182169
183- export class ZshStartupProvider implements ShellStartupScriptProvider {
184- public readonly name : string = 'zsh' ;
185- public readonly shellType : string = ShellConstants . ZSH ;
186-
187- private async checkShellInstalled ( ) : Promise < boolean > {
188- const found = await isZshInstalled ( ) ;
189- if ( ! found ) {
190- traceInfo ( '`zsh` was not found on the system' , 'If it is installed make sure it is available on `PATH`' ) ;
191- }
192- return found ;
193- }
194-
195- async isSetup ( ) : Promise < ShellSetupState > {
196- const found = await this . checkShellInstalled ( ) ;
197- if ( ! found ) {
198- return ShellSetupState . NotInstalled ;
199- }
200-
201- try {
202- const zshProfiles = await getZshProfiles ( ) ;
203- return await isStartupSetup ( zshProfiles , ZSH_ENV_KEY ) ;
204- } catch ( err ) {
205- traceError ( 'Failed to check zsh startup scripts' , err ) ;
206- return ShellSetupState . NotSetup ;
207- }
208- }
209-
210- async setupScripts ( ) : Promise < ShellScriptEditState > {
211- const found = await this . checkShellInstalled ( ) ;
212- if ( ! found ) {
213- return ShellScriptEditState . NotInstalled ;
214- }
215- try {
216- const zshProfiles = await getZshProfiles ( ) ;
217- const result = await setupStartup ( zshProfiles , ZSH_ENV_KEY , this . name ) ;
218- return result ? ShellScriptEditState . Edited : ShellScriptEditState . NotEdited ;
219- } catch ( err ) {
220- traceError ( 'Failed to setup zsh startup scripts' , err ) ;
221- return ShellScriptEditState . NotEdited ;
222- }
223- }
224-
225- async teardownScripts ( ) : Promise < ShellScriptEditState > {
226- const found = await this . checkShellInstalled ( ) ;
227- if ( ! found ) {
228- return ShellScriptEditState . NotInstalled ;
229- }
230- try {
231- const zshProfiles = await getZshProfiles ( ) ;
232- await removeStartup ( zshProfiles , ZSH_OLD_ENV_KEY ) ;
233- const result = await removeStartup ( zshProfiles , ZSH_ENV_KEY ) ;
234- return result ? ShellScriptEditState . Edited : ShellScriptEditState . NotEdited ;
235- } catch ( err ) {
236- traceError ( 'Failed to teardown zsh startup scripts' , err ) ;
237- return ShellScriptEditState . NotEdited ;
238- }
239- }
240- clearCache ( ) : Promise < void > {
241- return Promise . resolve ( ) ;
242- }
243- }
244-
245170export class GitBashStartupProvider implements ShellStartupScriptProvider {
246171 public readonly name : string = 'Git bash' ;
247172 public readonly shellType : string = ShellConstants . GITBASH ;
0 commit comments