Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wrapper for dirs_next::config_dir() #6837

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions crates/turborepo-dirs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "turborepo-dirs"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dirs-next = "2.0.0"

[lints]
workspace = true
14 changes: 14 additions & 0 deletions crates/turborepo-dirs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::path::PathBuf;

use dirs_next::config_dir as dirs_config_dir;

/// Returns the path to the user's configuration directory. This is a wrapper
/// around `dirs_next::config_dir` that also checks the `TURBO_CONFIG_DIR_PATH`
/// environment variable. If the environment variable is set, it will return
/// that path instead of `dirs_next::config_dir`.
pub fn config_dir() -> Option<PathBuf> {
if let Ok(dir) = std::env::var("TURBO_CONFIG_DIR_PATH") {
return Some(PathBuf::from(dir));
}
dirs_config_dir()
}
Loading