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 9d330d1
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,45 +120,45 @@ VisualStudioFinder.prototype = {

this.log.error(`\n${errorLog}\n\n${infoLog}\n`)
process.nextTick(this.callback.bind(null, new Error(
'Could not find any Visual Studio installation to use')))
'Could not find any Visual Studio installation to use')))
},

// 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 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 9d330d1

Please sign in to comment.