@@ -6,6 +6,19 @@ import * as path from 'path';
66import { traceError , traceInfo , traceVerbose } from '../../common/logging' ;
77import { isWindows } from '../../common/utils/platformUtils' ;
88
9+ /**
10+ * Shell-specific sourcing scripts for conda activation.
11+ * Each field is optional since not all scripts may be available on all systems.
12+ */
13+ export interface ShellSourcingScripts {
14+ /** PowerShell hook script (conda-hook.ps1) */
15+ ps1 ?: string ;
16+ /** Bash/sh initialization script (conda.sh) */
17+ sh ?: string ;
18+ /** Windows CMD batch file (activate.bat) */
19+ cmd ?: string ;
20+ }
21+
922/**
1023 * Represents the status of conda sourcing in the current environment
1124 */
@@ -16,14 +29,14 @@ export class CondaSourcingStatus {
1629 * @param condaFolder Path to the conda installation folder (derived from condaPath)
1730 * @param isActiveOnLaunch Whether conda was activated before VS Code launch
1831 * @param globalSourcingScript Path to the global sourcing script (if exists)
19- * @param shellSourcingScripts List of paths to shell -specific sourcing scripts
32+ * @param shellSourcingScripts Shell -specific sourcing scripts (if found)
2033 */
2134 constructor (
2235 public readonly condaPath : string ,
2336 public readonly condaFolder : string ,
2437 public isActiveOnLaunch ?: boolean ,
2538 public globalSourcingScript ?: string ,
26- public shellSourcingScripts ?: string [ ] ,
39+ public shellSourcingScripts ?: ShellSourcingScripts ,
2740 ) { }
2841
2942 /**
@@ -40,15 +53,23 @@ export class CondaSourcingStatus {
4053 lines . push ( `├─ Global Sourcing Script: ${ this . globalSourcingScript } ` ) ;
4154 }
4255
43- if ( this . shellSourcingScripts ?. length ) {
44- lines . push ( '└─ Shell-specific Sourcing Scripts:' ) ;
45- this . shellSourcingScripts . forEach ( ( script , index , array ) => {
46- const isLast = index === array . length - 1 ;
47- if ( script ) {
48- // Only include scripts that exist
49- lines . push ( ` ${ isLast ? '└─' : '├─' } ${ script } ` ) ;
50- }
51- } ) ;
56+ if ( this . shellSourcingScripts ) {
57+ const scripts = this . shellSourcingScripts ;
58+ const entries = [
59+ scripts . ps1 && `PowerShell: ${ scripts . ps1 } ` ,
60+ scripts . sh && `Bash/sh: ${ scripts . sh } ` ,
61+ scripts . cmd && `CMD: ${ scripts . cmd } ` ,
62+ ] . filter ( Boolean ) ;
63+
64+ if ( entries . length > 0 ) {
65+ lines . push ( '└─ Shell-specific Sourcing Scripts:' ) ;
66+ entries . forEach ( ( entry , index , array ) => {
67+ const isLast = index === array . length - 1 ;
68+ lines . push ( ` ${ isLast ? '└─' : '├─' } ${ entry } ` ) ;
69+ } ) ;
70+ } else {
71+ lines . push ( '└─ No Shell-specific Sourcing Scripts Found' ) ;
72+ }
5273 } else {
5374 lines . push ( '└─ No Shell-specific Sourcing Scripts Found' ) ;
5475 }
@@ -120,7 +141,7 @@ export async function findGlobalSourcingScript(condaFolder: string): Promise<str
120141 }
121142}
122143
123- export async function findShellSourcingScripts ( sourcingStatus : CondaSourcingStatus ) : Promise < string [ ] > {
144+ export async function findShellSourcingScripts ( sourcingStatus : CondaSourcingStatus ) : Promise < ShellSourcingScripts > {
124145 const logs : string [ ] = [ ] ;
125146 logs . push ( '=== Conda Sourcing Shell Script Search ===' ) ;
126147
@@ -170,7 +191,7 @@ export async function findShellSourcingScripts(sourcingStatus: CondaSourcingStat
170191 traceVerbose ( logs . join ( '\n' ) ) ;
171192 }
172193
173- return [ ps1Script , shScript , cmdActivate ] as string [ ] ;
194+ return { ps1 : ps1Script , sh : shScript , cmd : cmdActivate } ;
174195}
175196
176197/**
0 commit comments