Don't run APM on BSDs (fix #68)
This commit is contained in:
@@ -9,8 +9,16 @@ use std::process::Command;
|
|||||||
const EMACS_UPGRADE: &str = include_str!("emacs.el");
|
const EMACS_UPGRADE: &str = include_str!("emacs.el");
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn run_cargo_update(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
pub fn run_cargo_update(
|
||||||
if let Some(cargo_update) = base_dirs.home_dir().join(".cargo/bin/cargo-install-update").if_exists() {
|
base_dirs: &BaseDirs,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> Option<(&'static str, bool)> {
|
||||||
|
if let Some(cargo_update) = base_dirs
|
||||||
|
.home_dir()
|
||||||
|
.join(".cargo/bin/cargo-install-update")
|
||||||
|
.if_exists()
|
||||||
|
{
|
||||||
terminal.print_separator("Cargo");
|
terminal.print_separator("Cargo");
|
||||||
|
|
||||||
let success = || -> Result<(), Error> {
|
let success = || -> Result<(), Error> {
|
||||||
@@ -30,7 +38,11 @@ pub fn run_cargo_update(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn run_gem(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
pub fn run_gem(
|
||||||
|
base_dirs: &BaseDirs,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> Option<(&'static str, bool)> {
|
||||||
if let Some(gem) = utils::which("gem") {
|
if let Some(gem) = utils::which("gem") {
|
||||||
if base_dirs.home_dir().join(".gem").exists() {
|
if base_dirs.home_dir().join(".gem").exists() {
|
||||||
terminal.print_separator("RubyGems");
|
terminal.print_separator("RubyGems");
|
||||||
@@ -52,15 +64,24 @@ pub fn run_gem(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn run_emacs(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
pub fn run_emacs(
|
||||||
|
base_dirs: &BaseDirs,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> Option<(&'static str, bool)> {
|
||||||
if let Some(emacs) = utils::which("emacs") {
|
if let Some(emacs) = utils::which("emacs") {
|
||||||
if let Some(init_file) = base_dirs.home_dir().join(".emacs.d/init.el").if_exists() {
|
if let Some(init_file) = base_dirs.home_dir().join(".emacs.d/init.el").if_exists() {
|
||||||
terminal.print_separator("Emacs");
|
terminal.print_separator("Emacs");
|
||||||
|
|
||||||
let success = || -> Result<(), Error> {
|
let success = || -> Result<(), Error> {
|
||||||
Executor::new(&emacs, dry_run)
|
Executor::new(&emacs, dry_run)
|
||||||
.args(&["--batch", "-l", init_file.to_str().unwrap(), "--eval", EMACS_UPGRADE])
|
.args(&[
|
||||||
.spawn()?
|
"--batch",
|
||||||
|
"-l",
|
||||||
|
init_file.to_str().unwrap(),
|
||||||
|
"--eval",
|
||||||
|
EMACS_UPGRADE,
|
||||||
|
]).spawn()?
|
||||||
.wait()?
|
.wait()?
|
||||||
.check()?;
|
.check()?;
|
||||||
|
|
||||||
@@ -74,6 +95,16 @@ pub fn run_emacs(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[cfg(
|
||||||
|
not(
|
||||||
|
any(
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "openbsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "dragonfly"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)]
|
||||||
pub fn run_apm(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
pub fn run_apm(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
||||||
if let Some(apm) = utils::which("apm") {
|
if let Some(apm) = utils::which("apm") {
|
||||||
terminal.print_separator("Atom Package Manager");
|
terminal.print_separator("Atom Package Manager");
|
||||||
@@ -95,7 +126,11 @@ pub fn run_apm(terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn run_rustup(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool) -> Option<(&'static str, bool)> {
|
pub fn run_rustup(
|
||||||
|
base_dirs: &BaseDirs,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> Option<(&'static str, bool)> {
|
||||||
if let Some(rustup) = utils::which("rustup") {
|
if let Some(rustup) = utils::which("rustup") {
|
||||||
terminal.print_separator("rustup");
|
terminal.print_separator("rustup");
|
||||||
|
|
||||||
@@ -108,7 +143,11 @@ pub fn run_rustup(base_dirs: &BaseDirs, terminal: &mut Terminal, dry_run: bool)
|
|||||||
.check()?;
|
.check()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Executor::new(&rustup, dry_run).arg("update").spawn()?.wait()?.check()?;
|
Executor::new(&rustup, dry_run)
|
||||||
|
.arg("update")
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}().is_ok();
|
}().is_ok();
|
||||||
|
|
||||||
@@ -124,8 +163,16 @@ pub fn run_opam_update(terminal: &mut Terminal, dry_run: bool) -> Option<(&'stat
|
|||||||
terminal.print_separator("OCaml Package Manager");
|
terminal.print_separator("OCaml Package Manager");
|
||||||
|
|
||||||
let success = || -> Result<(), Error> {
|
let success = || -> Result<(), Error> {
|
||||||
Executor::new(&opam, dry_run).arg("update").spawn()?.wait()?.check()?;
|
Executor::new(&opam, dry_run)
|
||||||
Executor::new(&opam, dry_run).arg("upgrade").spawn()?.wait()?.check()?;
|
.arg("update")
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
|
Executor::new(&opam, dry_run)
|
||||||
|
.arg("upgrade")
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.check()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}().is_ok();
|
}().is_ok();
|
||||||
|
|
||||||
@@ -136,7 +183,12 @@ pub fn run_opam_update(terminal: &mut Terminal, dry_run: bool) -> Option<(&'stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn run_custom_command(name: &str, command: &str, terminal: &mut Terminal, dry_run: bool) -> Result<(), Error> {
|
pub fn run_custom_command(
|
||||||
|
name: &str,
|
||||||
|
command: &str,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> Result<(), Error> {
|
||||||
terminal.print_separator(name);
|
terminal.print_separator(name);
|
||||||
Executor::new("sh", dry_run)
|
Executor::new("sh", dry_run)
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -238,6 +238,17 @@ fn run() -> Result<(), Error> {
|
|||||||
|terminal| node::yarn_global_update(terminal, opt.dry_run),
|
|terminal| node::yarn_global_update(terminal, opt.dry_run),
|
||||||
&mut terminal,
|
&mut terminal,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
#[cfg(
|
||||||
|
not(
|
||||||
|
any(
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "openbsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "dragonfly"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)]
|
||||||
report.push_result(execute(
|
report.push_result(execute(
|
||||||
|terminal| generic::run_apm(terminal, opt.dry_run),
|
|terminal| generic::run_apm(terminal, opt.dry_run),
|
||||||
&mut terminal,
|
&mut terminal,
|
||||||
|
|||||||
Reference in New Issue
Block a user