Pass -y to WSL if necessary

This commit is contained in:
Roey Darwish Dror
2020-08-21 21:10:54 +03:00
parent 7af1e3889a
commit d48182e6bd
2 changed files with 11 additions and 6 deletions

View File

@@ -110,7 +110,7 @@ fn run() -> Result<()> {
let should_run_powershell = powershell.profile().is_some() && config.should_run(Step::Powershell); let should_run_powershell = powershell.profile().is_some() && config.should_run(Step::Powershell);
#[cfg(windows)] #[cfg(windows)]
runner.execute(Step::Wsl, "WSL", || windows::run_wsl_topgrade(run_type))?; runner.execute(Step::Wsl, "WSL", || windows::run_wsl_topgrade(&ctx))?;
if let Some(topgrades) = config.remote_topgrades() { if let Some(topgrades) = config.remote_topgrades() {
for remote_topgrade in topgrades.iter().filter(|t| config.should_execute_remote(t)) { for remote_topgrade in topgrades.iter().filter(|t| config.should_execute_remote(t)) {

View File

@@ -47,18 +47,23 @@ pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {
Ok(()) Ok(())
} }
pub fn run_wsl_topgrade(run_type: RunType) -> Result<()> { pub fn run_wsl_topgrade(ctx: &ExecutionContext) -> Result<()> {
let wsl = require("wsl")?; let wsl = require("wsl")?;
let topgrade = Command::new(&wsl) let topgrade = Command::new(&wsl)
.args(&["which", "topgrade"]) .args(&["which", "topgrade"])
.check_output() .check_output()
.map_err(|_| SkipStep)?; .map_err(|_| SkipStep)?;
run_type let mut command = ctx.run_type().execute(&wsl);
.execute(&wsl) command
.args(&["bash", "-c"]) .args(&["bash", "-c"])
.arg(format!("TOPGRADE_PREFIX=WSL exec {}", topgrade)) .arg(format!("TOPGRADE_PREFIX=WSL exec {}", topgrade));
.check_run()
if ctx.config().yes() {
command.arg("-y");
}
command.check_run()
} }
pub fn windows_update(ctx: &ExecutionContext) -> Result<()> { pub fn windows_update(ctx: &ExecutionContext) -> Result<()> {