-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-RubyVersion.ps1
More file actions
41 lines (34 loc) · 1.2 KB
/
Remove-RubyVersion.ps1
File metadata and controls
41 lines (34 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function Remove-RubyVersion {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, ParameterSetName = 'Shell')]
[switch] $Shell,
[Parameter(Mandatory, ParameterSetName = 'Local')]
[switch] $Local
)
$callerErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = [Management.Automation.ActionPreference]::Stop
try {
$previousVersion = Get-RubyVersion
switch -Exact ($PSCmdlet.ParameterSetName) {
'Shell' {
Set-Item -Path Env:RBENV_VERSION_OLD -Value $Env:RBENV_VERSION -WhatIf:$WhatIfPreference
Remove-Item -Path Env:RBENV_VERSION -WhatIf:$WhatIfPreference
break
}
'Local' {
$versionFile = Join-Path $PWD .ruby-version
Remove-Item $versionFile -Force -WhatIf:$WhatIfPreference
break
}
}
$currentVersion = Get-RubyVersion
if ($previousVersion.Path.FullName -ne $currentVersion.Path.FullName) {
Update-RubyShims
}
}
catch {
$global:Error.RemoveAt(0)
Write-Error $_ -ErrorAction $callerErrorActionPreference
}
}