private/Tests/Test-CommandVSCode.ps1

function Test-CommandVSCode {
    <#
    .SYNOPSIS
        Returns $true when the Visual Studio Code 'code' 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\bin\code.cmd
          $env:ProgramFiles\Microsoft VS Code\bin\code.cmd
 
    Dependencies: None
    #>

    [OutputType([bool])]
    param ()

    if (Get-Command -Name 'code' -ErrorAction SilentlyContinue) {
        return $true
    }

    $fallbackPaths = @(
        (Join-Path $env:LOCALAPPDATA 'Programs\Microsoft VS Code\bin\code.cmd'),
        (Join-Path $env:ProgramFiles  'Microsoft VS Code\bin\code.cmd')
    )

    foreach ($path in $fallbackPaths) {
        if (Test-Path -Path $path) {
            return $true
        }
    }

    return $false
}