Pass --force to doom when -y is set (fix #799)

This commit is contained in:
Roey Darwish Dror
2021-11-18 20:45:34 +02:00
parent d01a3a2c9d
commit 1db6dc5470
2 changed files with 14 additions and 7 deletions

View File

@@ -292,7 +292,7 @@ fn run() -> Result<()> {
runner.execute(Step::Choosenim, "choosenim", || generic::run_choosenim(&ctx))?;
runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(&ctx))?;
runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(run_type))?;
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(run_type))?;
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?;
runner.execute(Step::Opam, "opam", || generic::run_opam_update(run_type))?;
runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(run_type))?;
runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(run_type))?;

View File

@@ -1,4 +1,4 @@
use crate::executor::RunType;
use crate::execution_context::ExecutionContext;
use crate::terminal::print_separator;
use crate::utils::{require, require_option, PathExt};
use anyhow::Result;
@@ -60,25 +60,32 @@ impl Emacs {
self.directory.as_ref()
}
fn update_doom(doom: &Path, run_type: RunType) -> Result<()> {
fn update_doom(doom: &Path, ctx: &ExecutionContext) -> Result<()> {
print_separator("Doom Emacs");
run_type.execute(doom).args(&["-y", "upgrade"]).check_run()
let mut command = ctx.run_type().execute(doom);
command.args(&["-y", "upgrade"]);
if ctx.config().yes() {
command.arg("--force");
}
command.check_run()
}
pub fn upgrade(&self, run_type: RunType) -> Result<()> {
pub fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
let emacs = require("emacs")?;
let init_file = require_option(self.directory.as_ref(), String::from("Emacs directory does not exist"))?
.join("init.el")
.require()?;
if let Some(doom) = &self.doom {
return Emacs::update_doom(doom, run_type);
return Emacs::update_doom(doom, ctx);
}
print_separator("Emacs");
let mut command = run_type.execute(&emacs);
let mut command = ctx.run_type().execute(&emacs);
command
.args(&["--batch", "--debug-init", "-l"])