mirror of
https://github.com/microsoft/vscode.git
synced 2026-06-04 14:46:07 +01:00
Update copilot cli powershell shim (#2656)
* Update copilot cli powershell shim * fixes * fixes * fixes * fixes
This commit is contained in:
@@ -14,6 +14,23 @@
|
||||
|
||||
# Minimum required Copilot CLI version
|
||||
$RequiredVersion = "0.0.342"
|
||||
$PackageName = "@github/copilot"
|
||||
|
||||
function Invoke-NpmGlobalCommand {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][ValidateSet('install', 'update')][string]$Command,
|
||||
[Parameter(Mandatory = $true)][string]$Package
|
||||
)
|
||||
|
||||
$npmArgs = @($Command, '-g', $Package)
|
||||
|
||||
$npmCmd = Get-Command npm.cmd -ErrorAction SilentlyContinue
|
||||
if ($npmCmd) {
|
||||
& npm.cmd @npmArgs
|
||||
} else {
|
||||
& npm @npmArgs
|
||||
}
|
||||
}
|
||||
|
||||
function Find-RealCopilot {
|
||||
# Find the real copilot binary, avoiding this script if it's in PATH
|
||||
@@ -73,7 +90,7 @@ function Test-AndLaunchCopilot {
|
||||
$answer = Read-Host "Install GitHub Copilot CLI? (y/N)"
|
||||
if ($answer -eq "y" -or $answer -eq "Y") {
|
||||
try {
|
||||
& npm install -g @github/copilot
|
||||
Invoke-NpmGlobalCommand -Command 'install' -Package $PackageName
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Test-AndLaunchCopilot $Arguments
|
||||
return
|
||||
@@ -98,7 +115,7 @@ function Test-AndLaunchCopilot {
|
||||
if ($answer -eq "y" -or $answer -eq "Y") {
|
||||
Write-Host "Reinstalling GitHub Copilot CLI..."
|
||||
try {
|
||||
& npm install -g @github/copilot
|
||||
Invoke-NpmGlobalCommand -Command 'install' -Package $PackageName
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Test-AndLaunchCopilot $Arguments
|
||||
return
|
||||
@@ -125,7 +142,7 @@ function Test-AndLaunchCopilot {
|
||||
$answer = Read-Host "Would you like to reinstall GitHub Copilot CLI? (y/N)"
|
||||
if ($answer -eq "y" -or $answer -eq "Y") {
|
||||
try {
|
||||
& npm install -g @github/copilot
|
||||
Invoke-NpmGlobalCommand -Command 'install' -Package $PackageName
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Test-AndLaunchCopilot $Arguments
|
||||
return
|
||||
@@ -159,7 +176,7 @@ function Test-AndLaunchCopilot {
|
||||
$answer = Read-Host "Reinstall GitHub Copilot CLI? (y/N)"
|
||||
if ($answer -eq "y" -or $answer -eq "Y") {
|
||||
try {
|
||||
& npm install -g @github/copilot
|
||||
Invoke-NpmGlobalCommand -Command 'install' -Package $PackageName
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Test-AndLaunchCopilot $Arguments
|
||||
return
|
||||
@@ -182,7 +199,7 @@ function Test-AndLaunchCopilot {
|
||||
$answer = Read-Host "Update GitHub Copilot CLI? (y/N)"
|
||||
if ($answer -eq "y" -or $answer -eq "Y") {
|
||||
try {
|
||||
& npm update -g @github/copilot
|
||||
Invoke-NpmGlobalCommand -Command 'update' -Package $PackageName
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Test-AndLaunchCopilot $Arguments
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user