Skip to content

Commit

Permalink
More clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhammond committed Aug 28, 2023
1 parent d28b8f8 commit e858225
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 41 deletions.
8 changes: 4 additions & 4 deletions crates/turborepo-lib/src/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ pub async fn link(

let before = base.local_config_path().read_to_string()?;
let after = set_path(&before, &["teamId"], team_id)?;
base.local_config_path().ensure_dir();
base.local_config_path().create_with_contents(after);
base.local_config_path().ensure_dir()?;
base.local_config_path().create_with_contents(after)?;

let chosen_team_name = match selected_team {
SelectedTeam::User => user_display_name,
Expand Down Expand Up @@ -246,8 +246,8 @@ pub async fn link(

let before = base.local_config_path().read_to_string()?;
let after = set_path(&before, &["spaces", "teamId"], team_id)?;
base.local_config_path().ensure_dir();
base.local_config_path().create_with_contents(after);
base.local_config_path().ensure_dir()?;
base.local_config_path().create_with_contents(after)?;

println!(
"
Expand Down
8 changes: 4 additions & 4 deletions crates/turborepo-lib/src/commands/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ pub async fn sso_login(base: &mut CommandBase, sso_team: &str) -> Result<()> {

let before = base.global_config_path()?.read_to_string()?;
let after = set_path(&before, &["token"], &verified_user.token)?;
base.global_config_path()?.ensure_dir();
base.global_config_path()?.create_with_contents(after);
base.global_config_path()?.ensure_dir()?;
base.global_config_path()?.create_with_contents(after)?;

println!(
"
Expand Down Expand Up @@ -130,8 +130,8 @@ pub async fn login(base: &mut CommandBase) -> Result<()> {

let before = base.global_config_path()?.read_to_string()?;
let after = set_path(&before, &["token"], token)?;
base.global_config_path()?.ensure_dir();
base.global_config_path()?.create_with_contents(after);
base.global_config_path()?.ensure_dir()?;
base.global_config_path()?.create_with_contents(after)?;

let client = base.api_client()?;
let user_response = client.get_user(token.as_str()).await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/logout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{commands::CommandBase, rewrite_json::unset_path};
pub fn logout(base: &mut CommandBase) -> Result<()> {
let before = base.global_config_path()?.read_to_string()?;
if let Some(after) = unset_path(&before, &["token"])? {
base.global_config_path()?.create_with_contents(after);
base.global_config_path()?.create_with_contents(after)?;
}

println!("{}", base.ui.apply(GREY.apply_to(">>> Logged out")));
Expand Down
8 changes: 4 additions & 4 deletions crates/turborepo-lib/src/commands/unlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ fn unlink_remote_caching(base: &mut CommandBase) -> Result<()> {
} else {
updated
};
base.local_config_path().ensure_dir();
base.local_config_path().create_with_contents(updated);
base.local_config_path().ensure_dir()?;
base.local_config_path().create_with_contents(updated)?;

"> Disabled Remote Caching"
} else {
Expand Down Expand Up @@ -65,8 +65,8 @@ fn unlink_spaces(base: &mut CommandBase) -> Result<()> {
} else {
updated
};
base.local_config_path().ensure_dir();
base.local_config_path().create_with_contents(updated);
base.local_config_path().ensure_dir()?;
base.local_config_path().create_with_contents(updated)?;
}

// Space config is _also_ in turbo.json.
Expand Down
27 changes: 0 additions & 27 deletions crates/turborepo-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
mod turbo;
mod turbo_config;

use std::path::PathBuf;

use camino::Utf8PathBuf;
use config::ConfigError;
#[cfg(not(windows))]
use dirs_next::config_dir;
// Go's xdg implementation uses FOLDERID_LocalAppData for config home
// https://github.com/adrg/xdg/blob/master/paths_windows.go#L28
// Rust xdg implementations uses FOLDERID_RoamingAppData for config home
// We use cache_dir so we can find the config dir that the Go code uses
#[cfg(windows)]
use dirs_next::data_local_dir as config_dir;
use thiserror::Error;
pub use turbo::{
validate_extends, validate_no_package_task_syntax, RawTurboJSON, SpacesJson, TurboJson,
Expand All @@ -38,8 +26,6 @@ pub enum Error {
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),
#[error(transparent)]
Config(#[from] ConfigError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Camino(#[from] camino::FromPathBufError),
Expand Down Expand Up @@ -68,16 +54,3 @@ pub enum Error {
#[error("No \"extends\" key found")]
NoExtends,
}

pub fn default_user_config_path() -> Result<Utf8PathBuf, Error> {
Ok(Utf8PathBuf::try_from(
config_dir()
.map(|p| p.join("turborepo").join("config.json"))
.ok_or(Error::NoDefaultConfigPath)?,
)?)
}

#[allow(dead_code)]
pub fn data_dir() -> Option<PathBuf> {
dirs_next::data_dir().map(|p| p.join("turborepo"))
}
2 changes: 2 additions & 0 deletions crates/turborepo-lib/src/config/turbo_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ impl TurborepoConfigBuilder {
fn local_config_path(&self) -> AbsoluteSystemPathBuf {
self.repo_root.join_components(&[".turbo", "config.json"])
}
#[allow(dead_code)]
fn root_package_json_path(&self) -> AbsoluteSystemPathBuf {
self.repo_root.join_component("package.json")
}
#[allow(dead_code)]
fn root_turbo_json_path(&self) -> AbsoluteSystemPathBuf {
self.repo_root.join_component("turbo.json")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Run {
};

let signature = if let Some(configuration_options) = &root_turbo_json.remote_cache_options {
configuration_options.signature.clone().unwrap_or_default()
configuration_options.signature.unwrap_or_default()
} else {
false
};
Expand Down

0 comments on commit e858225

Please sign in to comment.