Skip to content

Commit c03b739

Browse files
🪲 [Fix]: Disconnect-GithubAccount with Context and Silent parameters (#166)
## Description - `Disconnect-GithubAccount` with `Context` and `Silent` parameters - Fixes #165 ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 3d90cb5 commit c03b739

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/functions/public/Auth/Disconnect-GitHubAccount.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,25 @@
3636
# The context to log out of.
3737
[Parameter()]
3838
[Alias('Name')]
39-
[string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
39+
[string] $Context = (Get-GitHubConfig -Name 'DefaultContext'),
40+
41+
# Silently disconnects from GitHub.
42+
[switch] $Silent
4043
)
4144

4245
$commandName = $MyInvocation.MyCommand.Name
4346
Write-Verbose "[$commandName] - Start"
4447

45-
$Context = Get-GitHubConfig -Name 'DefaultContext'
4648
Remove-GitHubContext -Context $Context
47-
Remove-GitHubConfig -Name 'DefaultContext'
48-
49-
Write-Host '' -ForegroundColor Green -NoNewline
50-
Write-Host "Logged out of GitHub! [$Context]"
49+
$isDefaultContext = $Context -eq (Get-GitHubConfig -Name 'DefaultContext')
50+
if ($isDefaultContext) {
51+
Remove-GitHubConfig -Name 'DefaultContext'
52+
}
53+
54+
if (-not $Silent) {
55+
Write-Host '' -ForegroundColor Green -NoNewline
56+
Write-Host "Logged out of GitHub! [$Context]"
57+
}
5158

5259
Write-Verbose "[$commandName] - End"
5360
}

0 commit comments

Comments
 (0)