Use #[cfg] instead of if cfg!

This commit is contained in:
Roey Darwish Dror
2018-06-27 23:04:39 +03:00
parent 33a2b5d84c
commit c667e224a6
3 changed files with 27 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ use utils::is_ancestor;
const EMACS_UPGRADE: &str = include_str!("emacs.el");
#[cfg(unix)]
pub fn run_zplug(zsh: &PathBuf) -> Result<(), failure::Error> {
Command::new(zsh)
.args(&["-c", "source ~/.zshrc && zplug update"])
@@ -17,6 +18,7 @@ pub fn run_zplug(zsh: &PathBuf) -> Result<(), failure::Error> {
Ok(())
}
#[cfg(unix)]
pub fn run_tpm(tpm: &PathBuf) -> Result<(), failure::Error> {
Command::new(&tpm).arg("all").spawn()?.wait()?.check()?;
@@ -86,6 +88,7 @@ pub fn run_apm(apm: &PathBuf) -> Result<(), failure::Error> {
Ok(())
}
#[cfg(target_os = "linux")]
pub fn run_needrestart(sudo: &PathBuf) -> Result<(), failure::Error> {
Command::new(&sudo)
.arg("needrestart")
@@ -96,6 +99,7 @@ pub fn run_needrestart(sudo: &PathBuf) -> Result<(), failure::Error> {
Ok(())
}
#[cfg(target_os = "linux")]
pub fn run_fwupdmgr(fwupdmgr: &PathBuf) -> Result<(), failure::Error> {
Command::new(&fwupdmgr)
.arg("refresh")
@@ -126,6 +130,7 @@ pub fn run_rustup(rustup: &PathBuf) -> Result<(), failure::Error> {
Ok(())
}
#[cfg(target_os = "macos")]
pub fn upgrade_macos() -> Result<(), failure::Error> {
Command::new("softwareupdate")
.args(&["--install", "--all"])
@@ -163,6 +168,7 @@ pub fn run_custom_command(command: &str) -> Result<(), failure::Error> {
Ok(())
}
#[cfg(target_os = "linux")]
pub fn run_flatpak(flatpak: &PathBuf) -> Result<(), failure::Error> {
Command::new(&flatpak)
.arg("update")
@@ -173,6 +179,7 @@ pub fn run_flatpak(flatpak: &PathBuf) -> Result<(), failure::Error> {
Ok(())
}
#[cfg(target_os = "linux")]
pub fn run_snap(sudo: &PathBuf, snap: &PathBuf) -> Result<(), failure::Error> {
Command::new(&sudo)
.args(&[snap.to_str().unwrap(), "refresh"])