Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update-modules-unload-reload #977

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/steps/powershell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,34 @@ impl Powershell {

print_separator(t!("Powershell Modules Update"));

let mut cmd = vec!["Update-Module"];
let unload_cmd = ["Get-Module | Remove-Module -Force"];
let mut update_cmd = vec!["Update-Module"];
let reload_cmd = ["Get-Module -ListAvailable | Import-Module"];

if ctx.config().verbose() {
cmd.push("-Verbose")
update_cmd.push("-Verbose");
}

if ctx.config().yes(Step::Powershell) {
cmd.push("-Force")
update_cmd.push("-Force");
}

println!("{}", t!("Unloading modules..."));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Topgrade has added support for i18n, so we need to add translations for this "Unloading modules..." and "Reloading modules..." in line 94.

You can use ChatGPT or other LLM to get them translated.

ctx.run_type()
.execute(powershell)
.args(["-NoProfile", "-Command", &unload_cmd.join(" ")])
.status_checked()?;

println!("{}", t!("Updating modules..."));
ctx.run_type()
.execute(powershell)
// This probably doesn't need `shell_words::join`.
.args(["-NoProfile", "-Command", &cmd.join(" ")])
.args(["-NoProfile", "-Command", &update_cmd.join(" ")])
.status_checked()?;

println!("{}", t!("Reloading modules..."));
ctx.run_type()
.execute(powershell)
.args(["-NoProfile", "-Command", &reload_cmd.join(" ")])
.status_checked()
}

Expand Down