Skip to content

Commit

Permalink
feat: use env vars for debug features
Browse files Browse the repository at this point in the history
Instead of branching behaviour based on debug assertions,
check for environment variables and use those instead.
  • Loading branch information
mistydemeo committed Jan 24, 2024
1 parent 44ffb45 commit c38c2f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ pub fn get_latest_stable_release(
}

pub fn get_app_name() -> Option<String> {
if cfg!(debug_assertions) {
Some("cargo-dist".to_owned())
if let Some(name) = env::var("AXOUPDATER_APP_NAME").ok() {

Check failure on line 414 in src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

matching on `Some` with `ok()` is redundant

error: matching on `Some` with `ok()` is redundant --> src/lib.rs:414:5 | 414 | if let Some(name) = env::var("AXOUPDATER_APP_NAME").ok() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_result_ok = note: `-D clippy::match-result-ok` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::match_result_ok)]` help: consider matching on `Ok(name)` and removing the call to `ok` instead | 414 | if let Ok(name) = env::var("AXOUPDATER_APP_NAME") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some(name)
} else if let Some(path) = args().next() {
Utf8PathBuf::from(&path)
.file_name()
Expand All @@ -425,7 +425,7 @@ pub fn get_app_name() -> Option<String> {
}

pub fn get_config_path(app_name: &String) -> AxoupdateResult<Utf8PathBuf> {
if cfg!(debug_assertions) {
if env::var("AXOUPDATER_CONFIG_WORKING_DIR").is_ok() {
Ok(Utf8PathBuf::try_from(current_dir()?)?)
} else {
let Some(home) = homedir::get_my_home()? else {
Expand Down

0 comments on commit c38c2f5

Please sign in to comment.