Skip to content

Commit

Permalink
Fix version check
Browse files Browse the repository at this point in the history
  • Loading branch information
sam701 committed Oct 7, 2021
1 parent de25300 commit 41acdff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::{env, fs};
use ansi_term::{Color, Style};
use reqwest::Proxy;

use crate::version::VERSION;

pub fn path_to_absolute(path: &str) -> PathBuf {
let home = env::var("HOME").expect("HOME is not set");
let abs = path.replace("~", &home).replace("$HOME", &home);
Expand Down Expand Up @@ -35,6 +37,7 @@ pub fn get_https_client() -> Result<reqwest::blocking::Client, String> {
);
}
builder
.user_agent(format!("awscredx/{}", VERSION))
.build()
.map_err(|e| format!("cannot build http client: {}", e))
}
Expand Down
11 changes: 8 additions & 3 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ impl Display for PublishedVersion {
}

pub const VERSION: &str = env!("CARGO_PKG_VERSION");
const TRAVIS_OS_NAME_OPT: Option<&str> = option_env!("TRAVIS_OS_NAME");

// The environment variable is provided by github actions.
// See https://docs.github.com/en/actions/learn-github-actions/environment-variables
const CI_RUNNER_OS: Option<&str> = option_env!("RUNNER_OS");

pub fn print_version() {
println!(
Expand All @@ -58,8 +61,10 @@ pub fn print_version() {
}
}

fn os_name() -> &'static str {
TRAVIS_OS_NAME_OPT.unwrap_or("osx")
fn os_name() -> String {
CI_RUNNER_OS
.map(|s| s.to_lowercase())
.unwrap_or_else(|| "macos".to_owned())
}

pub fn check_new_version() -> Result<Option<PublishedVersion>, String> {
Expand Down

0 comments on commit 41acdff

Please sign in to comment.