diff --git a/src/shell/pwsh.rs b/src/shell/pwsh.rs index 1164c002d8..5f8e7e7891 100644 --- a/src/shell/pwsh.rs +++ b/src/shell/pwsh.rs @@ -89,7 +89,7 @@ impl Shell for Pwsh { }} }} __enable_mise_chpwd - Remove-Item -Path Function:/__enable_mise_chpwd + Remove-Item -ErrorAction SilentlyContinue -Path Function:/__enable_mise_chpwd function __enable_mise_prompt {{ if (-not $__mise_pwsh_previous_prompt_function){{ @@ -103,7 +103,7 @@ impl Shell for Pwsh { }} }} __enable_mise_prompt - Remove-Item -Path Function:/__enable_mise_prompt + Remove-Item -ErrorAction SilentlyContinue -Path Function:/__enable_mise_prompt _mise_hook "#}); @@ -136,7 +136,7 @@ impl Shell for Pwsh { }} }} __enable_mise_command_not_found - Remove-Item -Path Function:/__enable_mise_command_not_found + Remove-Item -ErrorAction SilentlyContinue -Path Function:/__enable_mise_command_not_found }} "#}); } @@ -145,10 +145,10 @@ impl Shell for Pwsh { fn deactivate(&self) -> String { formatdoc! {r#" - Remove-Item function:mise - Remove-Item -Path Env:/MISE_SHELL - Remove-Item -Path Env:/__MISE_WATCH - Remove-Item -Path Env:/__MISE_DIFF + Remove-Item -ErrorAction SilentlyContinue function:mise + Remove-Item -ErrorAction SilentlyContinue -Path Env:/MISE_SHELL + Remove-Item -ErrorAction SilentlyContinue -Path Env:/__MISE_WATCH + Remove-Item -ErrorAction SilentlyContinue -Path Env:/__MISE_DIFF "#} } @@ -166,7 +166,7 @@ impl Shell for Pwsh { fn unset_env(&self, k: &str) -> String { let k = powershell_escape(k.into()); - format!("Remove-Item -Path Env:/{k}\n") + format!("Remove-Item -ErrorAction SilentlyContinue -Path Env:/{k}\n") } } diff --git a/src/shell/snapshots/mise__shell__pwsh__tests__activate.snap b/src/shell/snapshots/mise__shell__pwsh__tests__activate.snap index c10e4566e4..29a987f999 100644 --- a/src/shell/snapshots/mise__shell__pwsh__tests__activate.snap +++ b/src/shell/snapshots/mise__shell__pwsh__tests__activate.snap @@ -1,6 +1,5 @@ --- source: src/shell/pwsh.rs -assertion_line: 235 expression: pwsh.activate(opts) snapshot_kind: text --- @@ -72,7 +71,7 @@ function __enable_mise_chpwd{ } } __enable_mise_chpwd -Remove-Item -Path Function:/__enable_mise_chpwd +Remove-Item -ErrorAction SilentlyContinue -Path Function:/__enable_mise_chpwd function __enable_mise_prompt { if (-not $__mise_pwsh_previous_prompt_function){ @@ -86,7 +85,7 @@ function __enable_mise_prompt { } } __enable_mise_prompt -Remove-Item -Path Function:/__enable_mise_prompt +Remove-Item -ErrorAction SilentlyContinue -Path Function:/__enable_mise_prompt _mise_hook if (-not $__mise_pwsh_command_not_found){ @@ -115,5 +114,5 @@ if (-not $__mise_pwsh_command_not_found){ } } __enable_mise_command_not_found - Remove-Item -Path Function:/__enable_mise_command_not_found + Remove-Item -ErrorAction SilentlyContinue -Path Function:/__enable_mise_command_not_found } diff --git a/src/shell/snapshots/mise__shell__pwsh__tests__deactivate.snap b/src/shell/snapshots/mise__shell__pwsh__tests__deactivate.snap index d87bfe2552..ca26017742 100644 --- a/src/shell/snapshots/mise__shell__pwsh__tests__deactivate.snap +++ b/src/shell/snapshots/mise__shell__pwsh__tests__deactivate.snap @@ -1,10 +1,9 @@ --- source: src/shell/pwsh.rs -assertion_line: 208 expression: replace_path(&deactivate) snapshot_kind: text --- -Remove-Item function:mise -Remove-Item -Path Env:/MISE_SHELL -Remove-Item -Path Env:/__MISE_WATCH -Remove-Item -Path Env:/__MISE_DIFF +Remove-Item -ErrorAction SilentlyContinue function:mise +Remove-Item -ErrorAction SilentlyContinue -Path Env:/MISE_SHELL +Remove-Item -ErrorAction SilentlyContinue -Path Env:/__MISE_WATCH +Remove-Item -ErrorAction SilentlyContinue -Path Env:/__MISE_DIFF diff --git a/src/shell/snapshots/mise__shell__pwsh__tests__unset_env.snap b/src/shell/snapshots/mise__shell__pwsh__tests__unset_env.snap index 28950b595a..b5e0ff2451 100644 --- a/src/shell/snapshots/mise__shell__pwsh__tests__unset_env.snap +++ b/src/shell/snapshots/mise__shell__pwsh__tests__unset_env.snap @@ -1,7 +1,6 @@ --- source: src/shell/pwsh.rs -assertion_line: 178 expression: "Pwsh::default().unset_env(\"FOO\")" snapshot_kind: text --- -Remove-Item -Path Env:/FOO +Remove-Item -ErrorAction SilentlyContinue -Path Env:/FOO