@@ -464,58 +464,64 @@ Write-Host ""
464464$originalLocation = Get-Location
465465
466466$cwcDir = Join-Path $env: USERPROFILE " .cwc"
467- $repoDir = Join-Path $cwcDir " repository"
468467
469468try {
470469
471470if (! (Test-Path $cwcDir )) {
472471 New-Item - ItemType Directory - Path $cwcDir | Out-Null
473472}
474473
475- $updated = $false
476- if (Test-Path (Join-Path $repoDir " .git" )) {
477- $updated = Invoke-Step " $msg_step_cloning ..." {
478- git - C $repoDir fetch origin main -- quiet * > $null
479- if ($LASTEXITCODE -ne 0 ) { throw " Failed to fetch" }
480- git - C $repoDir reset -- hard FETCH_HEAD -- quiet * > $null
481- if ($LASTEXITCODE -ne 0 ) { throw " Failed to reset" }
482- git - C $repoDir clean - fd -- quiet * > $null
483- if ($LASTEXITCODE -ne 0 ) { throw " Failed to clean" }
484- } $msg_step_cloning
485- }
474+ $indices = if ($installAll ) { 0 .. ($availableEditors.Count - 1 ) } else { $selectedIndex }
475+ foreach ($i in $indices ) {
476+ $editor = $availableEditors [$i ]
477+ $repoDir = Join-Path $cwcDir " repository-$ ( $editor.Scheme ) "
486478
487- if (-not $updated ) {
488- if (Test-Path $repoDir ) {
489- Remove-Item - Path $repoDir - Recurse - Force - ErrorAction SilentlyContinue
479+ if ($installAll ) {
480+ Write-Host " `n === $ ( $editor.Name ) ===" - ForegroundColor Cyan
490481 }
491- $null = Invoke-Step " $msg_step_cloning ..." {
492- git clone - b main - c core.longpaths= true -- quiet https:// github.com / CodeWebChat/ CWC.git $repoDir * > $null
493- if ($LASTEXITCODE -ne 0 ) { throw " Failed to clone" }
494- } $msg_step_cloning
495- }
496482
497- Set-Location $repoDir
483+ $updated = $false
484+ if (Test-Path (Join-Path $repoDir " .git" )) {
485+ $updated = Invoke-Step " $msg_step_cloning ..." {
486+ git - C $repoDir fetch origin main -- quiet * > $null
487+ if ($LASTEXITCODE -ne 0 ) { throw " Failed to fetch" }
488+ git - C $repoDir reset -- hard FETCH_HEAD -- quiet * > $null
489+ if ($LASTEXITCODE -ne 0 ) { throw " Failed to reset" }
490+ git - C $repoDir clean - fd -- quiet * > $null
491+ if ($LASTEXITCODE -ne 0 ) { throw " Failed to clean" }
492+ } $msg_step_cloning
493+ }
498494
499- $null = Invoke-Step " $msg_step_deps ..." {
500- npx.cmd -- yes pnpm install * > $null
501- } $msg_step_deps
495+ if (-not $updated ) {
496+ if (Test-Path $repoDir ) {
497+ Remove-Item - Path $repoDir - Recurse - Force - ErrorAction SilentlyContinue
498+ }
499+ $null = Invoke-Step " $msg_step_cloning ..." {
500+ git clone - b main - c core.longpaths= true -- quiet https:// github.com / CodeWebChat/ CWC.git $repoDir * > $null
501+ if ($LASTEXITCODE -ne 0 ) { throw " Failed to clone" }
502+ } $msg_step_cloning
503+ }
502504
503- Set-Location apps / editor
505+ Set-Location $repoDir
504506
505- Remove-Item * .vsix - Force - ErrorAction SilentlyContinue
507+ $null = Invoke-Step " $msg_step_deps ..." {
508+ npx.cmd -- yes pnpm install * > $null
509+ } $msg_step_deps
506510
507- $null = Invoke-Step " $msg_step_build ..." {
508- npx.cmd -- yes pnpm run build * > $null
509- } $msg_step_build
511+ Set-Location apps/ editor
510512
511- $vsixFile = Get-ChildItem * .vsix - ErrorAction SilentlyContinue | Select-Object - First 1
513+ Remove-Item * .vsix - Force - ErrorAction SilentlyContinue
512514
513- if (! $vsixFile ) {
514- Fail $msg_vsix_error
515- }
515+ $null = Invoke-Step " $msg_step_build ..." {
516+ npx.cmd -- yes pnpm run build * > $null
517+ } $msg_step_build
518+
519+ $vsixFile = Get-ChildItem * .vsix - ErrorAction SilentlyContinue | Select-Object - First 1
520+
521+ if (! $vsixFile ) {
522+ Fail $msg_vsix_error
523+ }
516524
517- function Install-ToEditor ($idx ) {
518- $editor = $availableEditors [$idx ]
519525 $ok = Invoke-Step " $msg_step_install $ ( $editor.Name ) ..." {
520526 & $editor.Cmd -- install-extension $vsixFile.FullName -- force * > $null
521527 }
@@ -530,12 +536,9 @@ function Install-ToEditor($idx) {
530536 } else {
531537 Write-Host " $msg_error $msg_install_fail $ ( $editor.Name ) ." - ForegroundColor Red
532538 }
533- }
534539
535- $indices = if ($installAll ) { 0 .. ($availableEditors.Count - 1 ) } else { $selectedIndex }
536- foreach ($i in $indices ) { Install-ToEditor $i }
537-
538- Set-Location $originalLocation
540+ Set-Location $originalLocation
541+ }
539542
540543} finally {
541544 Set-Location $originalLocation - ErrorAction SilentlyContinue
0 commit comments