Implement self-update

This commit is contained in:
Roey Darwish Dror
2018-11-07 14:31:44 +02:00
committed by Your Name
parent 24f8053b17
commit 6108637477
7 changed files with 1095 additions and 5 deletions

View File

@@ -19,6 +19,12 @@ extern crate nix;
#[cfg(unix)]
#[macro_use]
extern crate lazy_static;
#[cfg(all(
feature = "self-update",
any(windows, target_os = "linux", target_os = "macos")
))]
#[macro_use]
extern crate self_update;
extern crate walkdir;
#[cfg(target_os = "linux")]
@@ -114,20 +120,30 @@ fn run() -> Result<(), Error> {
}
env_logger::init();
let base_dirs = directories::BaseDirs::new().ok_or(NoBaseDirectories)?;
let git = Git::new();
let mut git_repos = Repositories::new(&git);
let mut execution_context = ExecutionContext {
terminal: Terminal::new(),
};
let base_dirs = directories::BaseDirs::new().ok_or(NoBaseDirectories)?;
let git = Git::new();
let mut git_repos = Repositories::new(&git);
let config = Config::read(&base_dirs)?;
let mut report = Report::new();
#[cfg(target_os = "linux")]
let sudo = utils::which("sudo");
#[cfg(all(
feature = "self-update",
any(windows, target_os = "linux", target_os = "macos")
))]
report.push_result(execute(
|terminal| generic::self_update(terminal, opt.dry_run),
&mut execution_context,
)?);
if let Some(commands) = config.pre_commands() {
for (name, command) in commands {
generic::run_custom_command(&name, &command, &mut execution_context.terminal, opt.dry_run)?;