Update snaps (fixes #29)
This commit is contained in:
@@ -37,6 +37,8 @@ Just run `topgrade`. It will run the following steps:
|
||||
* [Plug](https://github.com/junegunn/vim-plug)
|
||||
* Upgrade NPM globally installed packages
|
||||
* Upgrade Atom packages
|
||||
* *Linux*: Update Flatpak packages
|
||||
* *Linux*: Update snap packages
|
||||
* *Linux*: Run [fwupdmgr](https://github.com/hughsie/fwupd) to show firmware upgrade. (View
|
||||
only. No upgrades will actually be performed)
|
||||
* Run custom defined commands
|
||||
|
||||
19
src/main.rs
19
src/main.rs
@@ -171,11 +171,6 @@ fn run() -> Result<(), Error> {
|
||||
run_rustup(&rustup).report("rustup", &mut reports);
|
||||
}
|
||||
|
||||
if let Ok(flatpak) = which("flatpak") {
|
||||
terminal.print_separator("Flatpak");
|
||||
run_flatpak(&flatpak).report("Flatpak", &mut reports);
|
||||
}
|
||||
|
||||
let cargo_upgrade = home_path(".cargo/bin/cargo-install-update");
|
||||
if cargo_upgrade.exists() {
|
||||
terminal.print_separator("Cargo");
|
||||
@@ -214,6 +209,20 @@ fn run() -> Result<(), Error> {
|
||||
run_apm(&apm).report("Atom Package Manager", &mut reports);
|
||||
}
|
||||
|
||||
if cfg!(target_os = "linux") {
|
||||
if let Ok(flatpak) = which("flatpak") {
|
||||
terminal.print_separator("Flatpak");
|
||||
run_flatpak(&flatpak).report("Flatpak", &mut reports);
|
||||
}
|
||||
|
||||
if let Some(sudo) = &sudo {
|
||||
if let Ok(snap) = which("snap") {
|
||||
terminal.print_separator("snap");
|
||||
run_snap(&sudo, &snap).report("snap", &mut reports);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(commands) = config.commands() {
|
||||
for (name, command) in commands {
|
||||
terminal.print_separator(name);
|
||||
|
||||
10
src/steps.rs
10
src/steps.rs
@@ -162,3 +162,13 @@ pub fn run_flatpak(flatpak: &PathBuf) -> Result<(), failure::Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_snap(sudo: &PathBuf, snap: &PathBuf) -> Result<(), failure::Error> {
|
||||
Command::new(&sudo)
|
||||
.args(&[snap.to_str().unwrap(), "refresh"])
|
||||
.spawn()?
|
||||
.wait()?
|
||||
.check()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user