@@ -105,16 +105,18 @@ export class SessionManager implements Middleware {
105
105
106
106
this . createStatusBarItem ( ) ;
107
107
108
- // Check for OpenSSL dependency on macOS. Look for the default Homebrew installation
109
- // path and if that fails check the system-wide library path.
110
- if ( os . platform ( ) == "darwin" ) {
108
+ this . powerShellExePath = this . getPowerShellExePath ( ) ;
109
+
110
+ // Check for OpenSSL dependency on macOS when running PowerShell Core alpha. Look for the default
111
+ // Homebrew installation path and if that fails check the system-wide library path.
112
+ if ( os . platform ( ) == "darwin" && this . getPowerShellVersionLabel ( ) == "alpha" ) {
111
113
if ( ! ( utils . checkIfFileExists ( "/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib" ) &&
112
114
utils . checkIfFileExists ( "/usr/local/opt/openssl/lib/libssl.1.0.0.dylib" ) ) &&
113
115
! ( utils . checkIfFileExists ( "/usr/local/lib/libcrypto.1.0.0.dylib" ) &&
114
116
utils . checkIfFileExists ( "/usr/local/lib/libssl.1.0.0.dylib" ) ) ) {
115
117
var thenable =
116
118
vscode . window . showWarningMessage (
117
- "The PowerShell extension will not work without OpenSSL on macOS and OS X" ,
119
+ "The PowerShell extension will not work without OpenSSL on macOS and OS X when using PowerShell alpha " ,
118
120
"Show Documentation" ) ;
119
121
120
122
thenable . then (
@@ -131,7 +133,6 @@ export class SessionManager implements Middleware {
131
133
}
132
134
133
135
this . suppressRestartPrompt = false ;
134
- this . powerShellExePath = this . getPowerShellExePath ( ) ;
135
136
136
137
if ( this . powerShellExePath ) {
137
138
@@ -638,6 +639,33 @@ export class SessionManager implements Middleware {
638
639
return resolvedPath ;
639
640
}
640
641
642
+ private getPowerShellVersionLabel ( ) : string {
643
+ if ( this . powerShellExePath ) {
644
+ var powerShellCommandLine = [
645
+ this . powerShellExePath ,
646
+ "-NoProfile" ,
647
+ "-NonInteractive"
648
+ ] ;
649
+
650
+ // Only add ExecutionPolicy param on Windows
651
+ if ( utils . isWindowsOS ( ) ) {
652
+ powerShellCommandLine . push ( "-ExecutionPolicy" , "Bypass" )
653
+ }
654
+
655
+ powerShellCommandLine . push (
656
+ "-Command" ,
657
+ "'$PSVersionTable | ConvertTo-Json'" ) ;
658
+
659
+ var powerShellOutput = cp . execSync ( powerShellCommandLine . join ( ' ' ) ) ;
660
+ var versionDetails = JSON . parse ( powerShellOutput . toString ( ) ) ;
661
+ return versionDetails . PSVersion . Label ;
662
+ }
663
+ else {
664
+ // TODO: throw instead?
665
+ return null ;
666
+ }
667
+ }
668
+
641
669
private showSessionConsole ( isExecute ?: boolean ) {
642
670
if ( this . languageServerProcess ) {
643
671
this . languageServerProcess . showConsole (
0 commit comments