Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-k committed Jan 10, 2023
1 parent 52c55df commit 0fec41c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion flux-bin/src/bin/rustc-flux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use std::{

use anyhow::Result;
use flux_bin::utils::{
extend_env_var_with_path, get_ld_library_path, get_rust_toolchain, EXIT_ERR, LIB_PATH, get_flux_path,
extend_env_var_with_path, get_flux_path, get_ld_library_path, get_rust_toolchain, EXIT_ERR,
LIB_PATH,
};

fn main() {
Expand Down
17 changes: 7 additions & 10 deletions flux-bin/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@ pub const LIB_PATH: &str = "DYLD_FALLBACK_LIBRARY_PATH";
pub const EXIT_ERR: i32 = -1;

pub fn get_default_flux_path() -> Result<PathBuf> {
let mut default_flux_path = env::current_exe()
.map(|path| path.with_file_name("flux"))?;
let mut default_flux_path = env::current_exe().map(|path| path.with_file_name("flux"))?;
if cfg!(target_os = "windows") {
default_flux_path.set_extension("exe");
}
Ok(default_flux_path)
}

pub fn get_flux_path() -> Result<PathBuf> {
let flux_path = env::var("FLUX_PATH")
.map(PathBuf::from)
.or_else(|err| {
match err {
env::VarError::NotPresent => get_default_flux_path(),
_ => Err(anyhow::Error::from(err))
}
})?;
let flux_path = env::var("FLUX_PATH").map(PathBuf::from).or_else(|err| {
match err {
env::VarError::NotPresent => get_default_flux_path(),
_ => Err(anyhow::Error::from(err)),
}
})?;
if !flux_path.is_file() {
return Err(anyhow!("flux executable {:?} does not exist or is not a file", flux_path));
}
Expand Down

0 comments on commit 0fec41c

Please sign in to comment.