@@ -125,40 +125,40 @@ VisualStudioFinder.prototype = {
125
125
126
126
// Invoke the PowerShell script to get information about Visual Studio 2017
127
127
// or newer installations
128
- findVisualStudio2017OrNewer : function findVisualStudio2017OrNewer ( cb ) {
128
+ findVisualStudio2017OrNewer : function findVisualStudio2017OrNewer ( cb ) {
129
129
const ps = path . join ( process . env . SystemRoot , 'System32' , 'WindowsPowerShell' , 'v1.0' , 'powershell.exe' )
130
130
const csFile = path . join ( __dirname , 'Find-VisualStudio.cs' )
131
131
const basePsArgs = [ '-ExecutionPolicy' , 'Unrestricted' , '-NoProfile' , '-Command' , ]
132
132
const findLanguageModePsCmd =
133
- `&{ try { $ExecutionContext.SessionState.LanguageMode } catch { try { (Get-PSSessionConfiguration -Name Test).LanguageMode } catch { 'error' } } }`
133
+ `&{ try { $ExecutionContext.SessionState.LanguageMode } catch { try { (Get-PSSessionConfiguration -Name Test).LanguageMode } catch { 'error' } } }`
134
134
135
135
const psArgs = [ ...basePsArgs , findLanguageModePsCmd ]
136
136
this . log . silly ( 'Running' , ps , psArgs )
137
137
const childFindPsLanguageMode = execFile (
138
- ps ,
139
- psArgs ,
140
- { encoding : 'utf8' } ,
141
- ( err , stdout , stderr ) => {
142
- this . log . silly ( 'PS stderr = %j' , stderr )
143
- if ( err ) {
144
- this . log . silly ( 'PS err = %j' , err && ( err . stack || err ) )
145
- this . addLog (
146
- 'could not determine PowerShell LanguageMode, try re-running with \'--loglevel silly\' for more details' )
147
- return cb ( null )
148
- }
149
- const findVscDataPsCmd = `&{Add-Type -Path '${ csFile } ';[VisualStudioConfiguration.Main]::PrintJson()}`
150
- const psArgs = [ ...basePsArgs , findVscDataPsCmd ]
151
- // the Add-Type command requires powershell to run with languageMode == FullLanguage
152
- // Because languageMode feature is not introduced yet in powershell v2, we can try to use it.
153
- // If powershell v2 is not installed (a problem only if languageMode is not FullLanguage), then it is not
154
- // possible to use feature Add-Type.
155
- if ( stdout . toString ( 'utf8' ) . trim ( ) . toLowerCase ( ) !== 'fulllanguage' ) {
156
- psArgs . unshift ( '-Version' , '2' , )
157
- }
158
- this . log . silly ( 'Running' , ps , psArgs )
159
- const child = execFile ( ps , psArgs , { encoding : 'utf8' } , ( err , stdout , stderr ) => this . parseData ( err , stdout , stderr , cb ) )
160
- child . stdin . end ( )
161
- } )
138
+ ps ,
139
+ psArgs ,
140
+ { encoding : 'utf8' } ,
141
+ ( err , stdout , stderr ) => {
142
+ this . log . silly ( 'PS stderr = %j' , stderr )
143
+ if ( err ) {
144
+ this . log . silly ( 'PS err = %j' , err && ( err . stack || err ) )
145
+ this . addLog (
146
+ 'could not determine PowerShell LanguageMode, try re-running with \'--loglevel silly\' for more details' )
147
+ return cb ( null )
148
+ }
149
+ const findVscDataPsCmd = `&{Add-Type -Path '${ csFile } ';[VisualStudioConfiguration.Main]::PrintJson()}`
150
+ const psArgs = [ ...basePsArgs , findVscDataPsCmd ]
151
+ // the Add-Type command requires powershell to run with languageMode == FullLanguage
152
+ // Because languageMode feature is not introduced yet in powershell v2, we can try to use it.
153
+ // If powershell v2 is not installed (a problem only if languageMode is not FullLanguage), then it is not
154
+ // possible to use feature Add-Type.
155
+ if ( stdout . toString ( 'utf8' ) . trim ( ) . toLowerCase ( ) !== 'fulllanguage' ) {
156
+ psArgs . unshift ( '-Version' , '2' , )
157
+ }
158
+ this . log . silly ( 'Running' , ps , psArgs )
159
+ const child = execFile ( ps , psArgs , { encoding : 'utf8' } , ( err , stdout , stderr ) => this . parseData ( err , stdout , stderr , cb ) )
160
+ child . stdin . end ( )
161
+ } )
162
162
childFindPsLanguageMode . stdin . end ( )
163
163
} ,
164
164
0 commit comments