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 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions locales/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ _version: 2
es: "Actualizando módulos..."
fr: "Mise à jour des modules..."
zh_TW: "正在更新模組..."
"Unloading modules...":
en: "Unloading modules..."
es: "Descarga de módulos..."
fr: "Déchargement des modules..."
zh_TW: "正在卸載模組..."
"Reloading modules...":
en: "Reloading modules..."
es: "Módulos de recarga..."
fr: "Modules de rechargement..."
zh_TW: "正在重裝模組..."
"Powershell Modules Update":
en: "Powershell Modules Update"
es: "Actualización de módulos Powershell"
Expand Down
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..."));
niStee marked this conversation as resolved.
Show resolved Hide resolved
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