private/Tests/Test-CommandVSCodeInsiders.ps1
|
function Test-CommandVSCodeInsiders { <# .SYNOPSIS Returns $true when the Visual Studio Code Insiders 'code-insiders' command is available either in the current session PATH or at a known fallback location. .NOTES Author: David Segura Company: Recast Software Fallback paths checked (per-user install, then system-wide install): $env:LOCALAPPDATA\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd $env:ProgramFiles\Microsoft VS Code Insiders\bin\code-insiders.cmd #> [OutputType([bool])] param () if (Get-Command -Name 'code-insiders' -ErrorAction SilentlyContinue) { return $true } $fallbackPaths = @( (Join-Path $env:LOCALAPPDATA 'Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd'), (Join-Path $env:ProgramFiles 'Microsoft VS Code Insiders\bin\code-insiders.cmd') ) foreach ($path in $fallbackPaths) { if (Test-Path -Path $path) { return $true } } return $false } |