17
17
# https://github.com/PowerShell/PowerShellEditorServices/blob/master/module/Start-EditorServices.ps1
18
18
19
19
param (
20
- [Parameter (Mandatory = $true )]
21
- [ValidateNotNullOrEmpty ()]
22
- [string ]
23
- $EditorServicesVersion ,
24
-
25
20
[Parameter (Mandatory = $true )]
26
21
[ValidateNotNullOrEmpty ()]
27
22
[string ]
@@ -97,6 +92,13 @@ function ExitWithError($errorString) {
97
92
exit 1 ;
98
93
}
99
94
95
+ function WriteSessionFile ($sessionInfo ) {
96
+ $sessionInfoJson = ConvertTo-Json - InputObject $sessionInfo - Compress
97
+ Log " Writing session file with contents:"
98
+ Log $sessionInfoJson
99
+ $sessionInfoJson | Set-Content - Force - Path " $SessionDetailsPath " - ErrorAction Stop
100
+ }
101
+
100
102
# Are we running in PowerShell 2 or earlier?
101
103
if ($PSVersionTable.PSVersion.Major -le 2 ) {
102
104
# No ConvertTo-Json on PSv2 and below, so write out the JSON manually
@@ -106,12 +108,6 @@ if ($PSVersionTable.PSVersion.Major -le 2) {
106
108
ExitWithError " Unsupported PowerShell version $ ( $PSVersionTable.PSVersion ) , language features are disabled."
107
109
}
108
110
109
- function WriteSessionFile ($sessionInfo ) {
110
- $sessionInfoJson = ConvertTo-Json - InputObject $sessionInfo - Compress
111
- Log " Writing session file with contents:"
112
- Log $sessionInfoJson
113
- $sessionInfoJson | Set-Content - Force - Path " $SessionDetailsPath " - ErrorAction Stop
114
- }
115
111
116
112
if ($host.Runspace.LanguageMode -eq ' ConstrainedLanguage' ) {
117
113
WriteSessionFile @ {
@@ -244,32 +240,11 @@ if ((Test-ModuleAvailable "PowerShellGet") -eq $false) {
244
240
# TODO: WRITE ERROR
245
241
}
246
242
247
- # Check if the expected version of the PowerShell Editor Services
248
- # module is installed
249
- $parsedVersion = New-Object System.Version @ ($EditorServicesVersion )
250
- if ((Test-ModuleAvailable " PowerShellEditorServices" $parsedVersion ) -eq $false ) {
251
- if ($ConfirmInstall -and $isPS5orLater ) {
252
- # TODO: Check for error and return failure if necessary
253
- LogSection " Install PowerShellEditorServices"
254
- Install-Module " PowerShellEditorServices" - RequiredVersion $parsedVersion - Confirm
255
- }
256
- else {
257
- # Indicate to the client that the PowerShellEditorServices module
258
- # needs to be installed
259
- Write-Output " needs_install"
260
- }
261
- }
262
-
263
243
try {
264
244
LogSection " Start up PowerShellEditorServices"
265
245
Log " Importing PowerShellEditorServices"
266
246
267
- if ($isPS5orLater ) {
268
- Import-Module PowerShellEditorServices - RequiredVersion $parsedVersion - ErrorAction Stop
269
- }
270
- else {
271
- Import-Module PowerShellEditorServices - Version $parsedVersion - ErrorAction Stop
272
- }
247
+ Import-Module PowerShellEditorServices - ErrorAction Stop
273
248
274
249
# Locate available port numbers for services
275
250
Log " Searching for available socket port for the language service"
0 commit comments