Skip to content

Commit

Permalink
try to fix style issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascloarec committed Sep 14, 2022
1 parent 082bc54 commit a93bf54
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,40 +125,40 @@ VisualStudioFinder.prototype = {

// Invoke the PowerShell script to get information about Visual Studio 2017
// or newer installations
findVisualStudio2017OrNewer: function findVisualStudio2017OrNewer(cb) {
findVisualStudio2017OrNewer: function findVisualStudio2017OrNewer (cb) {
const ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
const basePsArgs = ['-ExecutionPolicy', 'Unrestricted', '-NoProfile', '-Command',]
const findLanguageModePsCmd =
`&{ try { $ExecutionContext.SessionState.LanguageMode } catch { try { (Get-PSSessionConfiguration -Name Test).LanguageMode } catch { 'error' } } }`
`&{ try { $ExecutionContext.SessionState.LanguageMode } catch { try { (Get-PSSessionConfiguration -Name Test).LanguageMode } catch { 'error' } } }`

const psArgs = [...basePsArgs, findLanguageModePsCmd]
this.log.silly('Running', ps, psArgs)
const childFindPsLanguageMode = execFile(
ps,
psArgs,
{encoding: 'utf8'},
(err, stdout, stderr) => {
this.log.silly('PS stderr = %j', stderr)
if (err) {
this.log.silly('PS err = %j', err && (err.stack || err))
this.addLog(
'could not determine PowerShell LanguageMode, try re-running with \'--loglevel silly\' for more details')
return cb(null)
}
const findVscDataPsCmd = `&{Add-Type -Path '${csFile}';[VisualStudioConfiguration.Main]::PrintJson()}`
const psArgs = [...basePsArgs, findVscDataPsCmd]
// the Add-Type command requires powershell to run with languageMode == FullLanguage
// Because languageMode feature is not introduced yet in powershell v2, we can try to use it.
// If powershell v2 is not installed (a problem only if languageMode is not FullLanguage), then it is not
// possible to use feature Add-Type.
if (stdout.toString('utf8').trim().toLowerCase() !== 'fulllanguage') {
psArgs.unshift('-Version', '2',)
}
this.log.silly('Running', ps, psArgs)
const child = execFile(ps, psArgs, {encoding: 'utf8'}, (err, stdout, stderr) => this.parseData(err, stdout, stderr, cb))
child.stdin.end()
})
ps,
psArgs,
{ encoding: 'utf8' },
(err, stdout, stderr) => {
this.log.silly('PS stderr = %j', stderr)
if (err) {
this.log.silly('PS err = %j', err && (err.stack || err))
this.addLog(
'could not determine PowerShell LanguageMode, try re-running with \'--loglevel silly\' for more details')
return cb(null)
}
const findVscDataPsCmd = `&{Add-Type -Path '${csFile}';[VisualStudioConfiguration.Main]::PrintJson()}`
const psArgs = [...basePsArgs, findVscDataPsCmd]
// the Add-Type command requires powershell to run with languageMode == FullLanguage
// Because languageMode feature is not introduced yet in powershell v2, we can try to use it.
// If powershell v2 is not installed (a problem only if languageMode is not FullLanguage), then it is not
// possible to use feature Add-Type.
if (stdout.toString('utf8').trim().toLowerCase() !== 'fulllanguage') {
psArgs.unshift('-Version', '2',)
}
this.log.silly('Running', ps, psArgs)
const child = execFile(ps, psArgs, { encoding: 'utf8' }, (err, stdout, stderr) => this.parseData(err, stdout, stderr, cb))
child.stdin.end()
})
childFindPsLanguageMode.stdin.end()
},

Expand Down

0 comments on commit a93bf54

Please sign in to comment.