-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-RbEnvRoot.ps1
More file actions
40 lines (32 loc) · 1.12 KB
/
Get-RbEnvRoot.ps1
File metadata and controls
40 lines (32 loc) · 1.12 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
<#
Display the root directory where versions and shims are kept.
E.g. `~/.rbenv`
#>
function Get-RbEnvRoot {
[CmdletBinding()]
[OutputType([IO.DirectoryInfo])]
param()
$callerErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = [Management.Automation.ActionPreference]::Stop
try {
if ($Env:RBENV_ROOT) {
$root = Get-Item $Env:RBENV_ROOT -Force -ErrorAction Ignore
if ($root.PSIsContainer) {
return $root
}
Write-Error "not a directory (`$Env:RBENV_ROOT): $Env:RBENV_ROOT" `
-RecommendedAction 'Set $Env:RBENV_ROOT to a valid directory.'
}
$rootPath = Join-Path $HOME .rbenv
$root = Get-Item $rootPath -Force -ErrorAction Ignore
if ($root.PSIsContainer) {
return $root
}
Write-Error "not a directory: $rootPath" `
-RecommendedAction 'Create the directory `~/.rbenv`, or set $Env:RBENV_ROOT to a valid directory.'
}
catch {
$global:Error.RemoveAt(0)
Write-Error $_ -ErrorAction $callerErrorActionPreference
}
}