File tree 2 files changed +52
-3
lines changed
2 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -116,11 +116,17 @@ export class PowerShellExeFinder {
116
116
* @param configuredPowerShellPath the PowerShell path configured by the user.
117
117
*/
118
118
public fixWindowsPowerShellPath ( configuredPowerShellPath : string ) : string {
119
+ const altWinPS = this . findWinPS ( { useAlternateBitness : true } ) ;
120
+
121
+ if ( ! altWinPS ) {
122
+ return configuredPowerShellPath ;
123
+ }
124
+
125
+ const lowerAltWinPSPath = altWinPS . exePath . toLocaleLowerCase ( ) ;
119
126
const lowerConfiguredPath = configuredPowerShellPath . toLocaleLowerCase ( ) ;
120
- const lowerAltWinPSPath = this . alternateBitnessWinPS . exePath . toLocaleLowerCase ( ) ;
121
127
122
128
if ( lowerConfiguredPath === lowerAltWinPSPath ) {
123
- return this . winPS . exePath ;
129
+ return this . findWinPS ( ) . exePath ;
124
130
}
125
131
126
132
return configuredPowerShellPath ;
@@ -180,7 +186,7 @@ export class PowerShellExeFinder {
180
186
// Currently it cannot take startup arguments to start PSES with.
181
187
//
182
188
// Look for the .NET global tool
183
- // yield this.pwshDotnetGlobalTool ;
189
+ // yield this.findPSCoreDotnetGlobalTool() ;
184
190
185
191
// Look for PSCore preview
186
192
yield this . findPSCorePreview ( ) ;
Original file line number Diff line number Diff line change @@ -594,4 +594,47 @@ suite("Platform module", () => {
594
594
} ) ;
595
595
}
596
596
} ) ;
597
+
598
+ suite ( "Windows PowerShell path fix" , ( ) => {
599
+ teardown ( ( ) => {
600
+ sinon . restore ( ) ;
601
+ mockFS . restore ( ) ;
602
+ } ) ;
603
+
604
+ for ( const testPlatform of successTestCases
605
+ . filter ( ( tp ) => tp . platformDetails . operatingSystem === platform . OperatingSystem . Windows ) ) {
606
+
607
+ test ( `Corrects the Windows PowerShell path on ${ testPlatform . name } ` , ( ) => {
608
+ setupTestEnvironment ( testPlatform ) ;
609
+
610
+ function getWinPSPath ( systemDir : string ) {
611
+ return path . join (
612
+ testPlatform . environmentVars . windir ,
613
+ systemDir ,
614
+ "WindowsPowerShell" ,
615
+ "v1.0" ,
616
+ "powershell.exe" ) ;
617
+ }
618
+
619
+ const winPSPath = getWinPSPath ( "System32" ) ;
620
+
621
+ let altWinPSPath ;
622
+ if ( testPlatform . platformDetails . isProcess64Bit ) {
623
+ altWinPSPath = getWinPSPath ( "SysWOW64" ) ;
624
+ } else if ( testPlatform . platformDetails . isOS64Bit ) {
625
+ altWinPSPath = getWinPSPath ( "Sysnative" ) ;
626
+ } else {
627
+ altWinPSPath = null ;
628
+ }
629
+
630
+ const powerShellExeFinder = new platform . PowerShellExeFinder ( testPlatform . platformDetails ) ;
631
+
632
+ assert . strictEqual ( powerShellExeFinder . fixWindowsPowerShellPath ( winPSPath ) , winPSPath ) ;
633
+
634
+ if ( altWinPSPath ) {
635
+ assert . strictEqual ( powerShellExeFinder . fixWindowsPowerShellPath ( altWinPSPath ) , winPSPath ) ;
636
+ }
637
+ } ) ;
638
+ }
639
+ } ) ;
597
640
} ) ;
You can’t perform that action at this time.
0 commit comments