@@ -5,6 +5,7 @@ import * as os from "os";
55import * as path from "path" ;
66import * as process from "process" ;
77import { integer } from "vscode-languageserver-protocol" ;
8+ import { Logger } from "./logging" ;
89import { PowerShellAdditionalExePathSettings } from "./settings" ;
910
1011// This uses require so we can rewire it in unit tests!
@@ -70,19 +71,9 @@ export function getPlatformDetails(): IPlatformDetails {
7071export class PowerShellExeFinder {
7172 // This is required, since parseInt("7-preview") will return 7.
7273 private static IntRegex = / ^ \d + $ / ;
73-
7474 private static PwshMsixRegex = / ^ M i c r o s o f t .P o w e r S h e l l _ .* / ;
75-
7675 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-
8476 private winPS : IPossiblePowerShellExe | undefined ;
85-
8677 private alternateBitnessWinPS : IPossiblePowerShellExe | undefined ;
8778
8879 /**
@@ -91,12 +82,11 @@ export class PowerShellExeFinder {
9182 * @param additionalPowerShellExes Additional PowerShell installations as configured in the settings.
9283 */
9384 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 ) { }
10090
10191 /**
10292 * Returns the first available PowerShell executable found in the search order.
@@ -159,6 +149,8 @@ export class PowerShellExeFinder {
159149 for ( const additionalPwsh of this . enumerateAdditionalPowerShellInstallations ( ) ) {
160150 if ( await additionalPwsh . exists ( ) ) {
161151 yield additionalPwsh ;
152+ } else {
153+ void this . logger . writeAndShowWarning ( `Additional PowerShell '${ additionalPwsh . displayName } ' not found at '${ additionalPwsh . exePath } '!` ) ;
162154 }
163155 }
164156 }
@@ -226,9 +218,9 @@ export class PowerShellExeFinder {
226218 * without checking for their existence.
227219 */
228220 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 ] ;
232224 if ( exePath ) {
233225 yield new PossiblePowerShellExe ( exePath , versionName ) ;
234226 }
0 commit comments