@@ -5,6 +5,7 @@ import * as os from "os";
5
5
import * as path from "path" ;
6
6
import * as process from "process" ;
7
7
import { integer } from "vscode-languageserver-protocol" ;
8
+ import { Logger } from "./logging" ;
8
9
import { PowerShellAdditionalExePathSettings } from "./settings" ;
9
10
10
11
// This uses require so we can rewire it in unit tests!
@@ -70,19 +71,9 @@ export function getPlatformDetails(): IPlatformDetails {
70
71
export class PowerShellExeFinder {
71
72
// This is required, since parseInt("7-preview") will return 7.
72
73
private static IntRegex = / ^ \d + $ / ;
73
-
74
74
private static PwshMsixRegex = / ^ M i c r o s o f t .P o w e r S h e l l _ .* / ;
75
-
76
75
private static PwshPreviewMsixRegex = / ^ M i c r o s o f t .P o w e r S h e l l P r e v i e w _ .* / ;
77
-
78
- // The platform details descriptor for the platform we're on
79
- private readonly platformDetails : IPlatformDetails ;
80
-
81
- // Additional configured PowerShells
82
- private readonly additionalPSExeSettings : PowerShellAdditionalExePathSettings ;
83
-
84
76
private winPS : IPossiblePowerShellExe | undefined ;
85
-
86
77
private alternateBitnessWinPS : IPossiblePowerShellExe | undefined ;
87
78
88
79
/**
@@ -91,12 +82,11 @@ export class PowerShellExeFinder {
91
82
* @param additionalPowerShellExes Additional PowerShell installations as configured in the settings.
92
83
*/
93
84
constructor (
94
- platformDetails ?: IPlatformDetails ,
95
- additionalPowerShellExes ?: PowerShellAdditionalExePathSettings ) {
96
-
97
- this . platformDetails = platformDetails ?? getPlatformDetails ( ) ;
98
- this . additionalPSExeSettings = additionalPowerShellExes ?? { } ;
99
- }
85
+ // The platform details descriptor for the platform we're on
86
+ private platformDetails : IPlatformDetails ,
87
+ // Additional configured PowerShells
88
+ private additionalPowerShellExes : PowerShellAdditionalExePathSettings ,
89
+ private logger : Logger ) { }
100
90
101
91
/**
102
92
* Returns the first available PowerShell executable found in the search order.
@@ -159,6 +149,8 @@ export class PowerShellExeFinder {
159
149
for ( const additionalPwsh of this . enumerateAdditionalPowerShellInstallations ( ) ) {
160
150
if ( await additionalPwsh . exists ( ) ) {
161
151
yield additionalPwsh ;
152
+ } else {
153
+ void this . logger . writeAndShowWarning ( `Additional PowerShell '${ additionalPwsh . displayName } ' not found at '${ additionalPwsh . exePath } '!` ) ;
162
154
}
163
155
}
164
156
}
@@ -226,9 +218,9 @@ export class PowerShellExeFinder {
226
218
* without checking for their existence.
227
219
*/
228
220
private * enumerateAdditionalPowerShellInstallations ( ) : Iterable < IPossiblePowerShellExe > {
229
- for ( const versionName in this . additionalPSExeSettings ) {
230
- if ( Object . prototype . hasOwnProperty . call ( this . additionalPSExeSettings , versionName ) ) {
231
- const exePath = this . additionalPSExeSettings [ versionName ] ;
221
+ for ( const versionName in this . additionalPowerShellExes ) {
222
+ if ( Object . prototype . hasOwnProperty . call ( this . additionalPowerShellExes , versionName ) ) {
223
+ const exePath = this . additionalPowerShellExes [ versionName ] ;
232
224
if ( exePath ) {
233
225
yield new PossiblePowerShellExe ( exePath , versionName ) ;
234
226
}
0 commit comments