Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Update snaps (fixes #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roey Darwish Dror committed Jun 14, 2018
1 parent 7a4c5a9 commit f2c487e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit f2c487e

Please sign in to comment.