diff --git a/aderyn/src/lib.rs b/aderyn/src/lib.rs index 31752b5b..b34af156 100644 --- a/aderyn/src/lib.rs +++ b/aderyn/src/lib.rs @@ -88,21 +88,23 @@ fn right_pad(s: &str, by: usize) -> String { pub static APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); -pub fn aderyn_is_currently_running_newest_version() -> Result { +pub fn aderyn_is_currently_running_newest_version() -> Option { let client = reqwest::blocking::Client::builder() .user_agent(APP_USER_AGENT) - .build()?; + .build() + .expect("client is unable to initialize"); let latest_version_checker = client .get("https://api.github.com/repos/Cyfrin/aderyn/releases/latest") - .send()?; + .send() + .ok()?; - let data = latest_version_checker.json::()?; - let newest = - Version::parse(data["tag_name"].as_str().unwrap().replace('v', "").as_str()).unwrap(); - let current = Version::parse(env!("CARGO_PKG_VERSION")).unwrap(); + let data = latest_version_checker.json::().ok()?; + let version_string = data["tag_name"].as_str()?; + let newest = Version::parse(version_string.replace('v', "").as_str()).ok()?; + let current = Version::parse(env!("CARGO_PKG_VERSION")).expect("Pkg version not available"); - Ok(current >= newest) + Some(current >= newest) } #[cfg(test)] @@ -111,6 +113,6 @@ mod latest_version_checker_tests { #[test] fn can_get_latest_version_from_crate_registry() { - assert!(aderyn_is_currently_running_newest_version().is_ok()) + assert!(aderyn_is_currently_running_newest_version().is_some()) } } diff --git a/aderyn/src/main.rs b/aderyn/src/main.rs index eda36a23..8c1a55df 100644 --- a/aderyn/src/main.rs +++ b/aderyn/src/main.rs @@ -141,7 +141,7 @@ fn main() { // Check for updates if !cmd_args.skip_update_check { - if let Ok(yes) = aderyn_is_currently_running_newest_version() { + if let Some(yes) = aderyn_is_currently_running_newest_version() { if !yes { println!(); println!("NEW VERSION OF ADERYN AVAILABLE! Please run `cyfrinup` to upgrade.");