(
wantedName?: string,
)
| 724 | } |
| 725 | |
| 726 | private async findPowerShell( |
| 727 | wantedName?: string, |
| 728 | ): Promise<IPowerShellExeDetails | undefined> { |
| 729 | this.logger.writeDebug("Finding PowerShell..."); |
| 730 | const powershellExeFinder = new PowerShellExeFinder( |
| 731 | this.platformDetails, |
| 732 | this.sessionSettings.powerShellAdditionalExePaths, |
| 733 | this.logger, |
| 734 | ); |
| 735 | |
| 736 | let foundPowerShell: IPowerShellExeDetails | undefined; |
| 737 | try { |
| 738 | let defaultPowerShell: IPowerShellExeDetails | undefined; |
| 739 | wantedName ??= this.sessionSettings.powerShellDefaultVersion; |
| 740 | if (wantedName !== "") { |
| 741 | for await (const details of powershellExeFinder.enumeratePowerShellInstallations()) { |
| 742 | // Need to compare names case-insensitively, from https://stackoverflow.com/a/2140723 |
| 743 | if ( |
| 744 | wantedName.localeCompare( |
| 745 | details.displayName, |
| 746 | undefined, |
| 747 | { sensitivity: "accent" }, |
| 748 | ) === 0 |
| 749 | ) { |
| 750 | defaultPowerShell = details; |
| 751 | break; |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | foundPowerShell = |
| 756 | defaultPowerShell ?? |
| 757 | (await powershellExeFinder.getFirstAvailablePowerShellInstallation()); |
| 758 | if ( |
| 759 | wantedName !== "" && |
| 760 | defaultPowerShell === undefined && |
| 761 | foundPowerShell !== undefined |
| 762 | ) { |
| 763 | void this.logger.writeAndShowWarning( |
| 764 | `The 'powerShellDefaultVersion' setting was '${wantedName}' but this was not found!` + |
| 765 | ` Instead using first available installation '${foundPowerShell.displayName}' at '${foundPowerShell.exePath}'!`, |
| 766 | ); |
| 767 | } |
| 768 | } catch (err) { |
| 769 | this.logger.writeError( |
| 770 | `Error occurred while searching for a PowerShell executable:\n${err}`, |
| 771 | ); |
| 772 | } |
| 773 | |
| 774 | return foundPowerShell; |
| 775 | } |
| 776 | |
| 777 | private async startLanguageServerProcess( |
| 778 | powerShellExeDetails: IPowerShellExeDetails, |
no test coverage detected