-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate-RubyShims.ps1
More file actions
44 lines (37 loc) · 1.14 KB
/
Update-RubyShims.ps1
File metadata and controls
44 lines (37 loc) · 1.14 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
42
43
44
function Update-RubyShims {
[CmdletBinding(SupportsShouldProcess)]
param()
$callerErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = [Management.Automation.ActionPreference]::Stop
try {
if ($PSCmdlet.ShouldProcess('Ruby Shims', 'Remove')) {
Remove-RubyShims
}
$version = Get-RubyVersion -ErrorAction Ignore
if (-not $version) {
return
}
foreach ($exec in $version.GetExecutables()) {
$type = Get-ExecutableType $exec
if (!$type) {
continue
}
if ($PSCmdlet.ShouldProcess($exec.FullName, 'Create Ruby Shim')) {
switch -Exact ($type) {
'Executable' {
New-RubyExecutableShim $exec
break
}
'Script' {
New-RubyScriptShim $exec
break
}
}
}
}
}
catch {
$global:Error.RemoveAt(0)
Write-Error $_ -ErrorAction $callerErrorActionPreference
}
}