refactor: remove unnecessary qualification (#443)
This commit is contained in:
@@ -40,7 +40,7 @@ pub enum Distribution {
|
||||
}
|
||||
|
||||
impl Distribution {
|
||||
fn parse_os_release(os_release: &ini::Ini) -> Result<Self> {
|
||||
fn parse_os_release(os_release: &Ini) -> Result<Self> {
|
||||
let section = os_release.general_section();
|
||||
let id = section.get("ID");
|
||||
let variant: Option<Vec<&str>> = section.get("VARIANT").map(|s| s.split_whitespace().collect());
|
||||
@@ -51,14 +51,14 @@ impl Distribution {
|
||||
Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS,
|
||||
Some("clear-linux-os") => Distribution::ClearLinux,
|
||||
Some("fedora") | Some("nobara") => {
|
||||
if let Some(variant) = variant {
|
||||
return if let Some(variant) = variant {
|
||||
if variant.contains(&"Silverblue") {
|
||||
return Ok(Distribution::FedoraSilverblue);
|
||||
Ok(Distribution::FedoraSilverblue)
|
||||
} else {
|
||||
return Ok(Distribution::Fedora);
|
||||
};
|
||||
Ok(Distribution::Fedora)
|
||||
}
|
||||
} else {
|
||||
return Ok(Distribution::Fedora);
|
||||
Ok(Distribution::Fedora)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,11 +81,11 @@ impl Distribution {
|
||||
return Ok(Distribution::CentOS);
|
||||
} else if id_like.contains(&"suse") {
|
||||
let id_variant = id.unwrap_or_default();
|
||||
if id_variant.contains("tumbleweed") {
|
||||
return Ok(Distribution::OpenSuseTumbleweed);
|
||||
return if id_variant.contains("tumbleweed") {
|
||||
Ok(Distribution::OpenSuseTumbleweed)
|
||||
} else {
|
||||
return Ok(Distribution::Suse);
|
||||
}
|
||||
Ok(Distribution::Suse)
|
||||
};
|
||||
} else if id_like.contains(&"arch") || id_like.contains(&"archlinux") {
|
||||
return Ok(Distribution::Arch);
|
||||
} else if id_like.contains(&"alpine") {
|
||||
|
||||
@@ -2,10 +2,7 @@ use std::fs;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::{
|
||||
env::{self, var},
|
||||
path::Path,
|
||||
};
|
||||
use std::{env::var, path::Path};
|
||||
|
||||
use crate::command::CommandExt;
|
||||
use crate::{Step, HOME_DIR};
|
||||
@@ -229,7 +226,7 @@ pub fn run_fundle(ctx: &ExecutionContext) -> Result<()> {
|
||||
pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
||||
let gdbus = require("gdbus")?;
|
||||
require_option(
|
||||
env::var("XDG_CURRENT_DESKTOP").ok().filter(|p| p.contains("GNOME")),
|
||||
var("XDG_CURRENT_DESKTOP").ok().filter(|p| p.contains("GNOME")),
|
||||
"Desktop doest not appear to be gnome".to_string(),
|
||||
)?;
|
||||
let output = Command::new("gdbus")
|
||||
@@ -407,7 +404,7 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
run_type.execute(nix_channel).arg("--update").status_checked()?;
|
||||
|
||||
if std::path::Path::new(&manifest_json_path).exists() {
|
||||
if Path::new(&manifest_json_path).exists() {
|
||||
run_type
|
||||
.execute(&nix)
|
||||
.arg("profile")
|
||||
@@ -466,7 +463,7 @@ pub fn run_pearl(ctx: &ExecutionContext) -> Result<()> {
|
||||
pub fn run_sdkman(cleanup: bool, ctx: &ExecutionContext) -> Result<()> {
|
||||
let bash = require("bash")?;
|
||||
|
||||
let sdkman_init_path = env::var("SDKMAN_DIR")
|
||||
let sdkman_init_path = var("SDKMAN_DIR")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| HOME_DIR.join(".sdkman"))
|
||||
.join("bin")
|
||||
@@ -476,7 +473,7 @@ pub fn run_sdkman(cleanup: bool, ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("SDKMAN!");
|
||||
|
||||
let sdkman_config_path = env::var("SDKMAN_DIR")
|
||||
let sdkman_config_path = var("SDKMAN_DIR")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| HOME_DIR.join(".sdkman"))
|
||||
.join("etc")
|
||||
|
||||
Reference in New Issue
Block a user