-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialize-RbEnv.ps1
More file actions
26 lines (20 loc) · 857 Bytes
/
Initialize-RbEnv.ps1
File metadata and controls
26 lines (20 loc) · 857 Bytes
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
function Initialize-RbEnv {
[CmdletBinding(SupportsShouldProcess)]
param()
$callerErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = [Management.Automation.ActionPreference]::Stop
try {
Update-RubyShims -WhatIf:$WhatIfPreference
if ($PSCmdlet.ShouldProcess('$ExecutionContext.SessionState.InvokeCommand', 'Registering LocationChangedAction')) {
$cmd = $global:ExecutionContext.SessionState.InvokeCommand
$cmd.LocationChangedAction = [Delegate]::Combine(
$cmd.LocationChangedAction,
[EventHandler[Management.Automation.LocationChangedEventArgs]] ([RbEnvLocationChanged]::OnLocationChanged)
)
}
}
catch {
$global:Error.RemoveAt(0)
Write-Error $_ -ErrorAction $callerErrorActionPreference
}
}