mirror of https://github.com/jdx/mise
feat: add more directory env var configs (#2056)
This commit is contained in:
parent
0b51f3bc31
commit
2e7587b84a
|
@ -18,5 +18,7 @@
|
|||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/mise-docs" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/usage" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
|
@ -4,7 +4,7 @@ repos:
|
|||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.6.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
#- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-json
|
||||
- id: check-toml
|
||||
|
|
|
@ -198,7 +198,7 @@ impl Doctor {
|
|||
}
|
||||
|
||||
fn shims_on_path() -> bool {
|
||||
env::PATH.contains(&*dirs::SHIMS)
|
||||
env::PATH.contains(&dirs::SHIMS.to_path_buf())
|
||||
}
|
||||
|
||||
fn yn(b: bool) -> String {
|
||||
|
@ -215,7 +215,7 @@ fn mise_dirs() -> String {
|
|||
("config", &*dirs::CONFIG),
|
||||
("cache", &*dirs::CACHE),
|
||||
("state", &*dirs::STATE),
|
||||
("shims", &dirs::SHIMS.as_path()),
|
||||
("shims", &*dirs::SHIMS),
|
||||
]
|
||||
.iter()
|
||||
.map(|(k, p)| format!("{k}: {}", display_path(p)))
|
||||
|
|
|
@ -386,7 +386,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_ls() {
|
||||
let _ = remove_all(dirs::INSTALLS.as_path());
|
||||
let _ = remove_all(*dirs::INSTALLS);
|
||||
assert_cli!("install");
|
||||
assert_cli_snapshot!("list", @r###"
|
||||
dummy ref:master ~/.test-tool-versions ref:master
|
||||
|
@ -430,7 +430,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_ls_json() {
|
||||
let _ = remove_all(dirs::INSTALLS.as_path());
|
||||
let _ = remove_all(*dirs::INSTALLS);
|
||||
assert_cli!("install");
|
||||
assert_cli_snapshot!("ls", "--json");
|
||||
assert_cli_snapshot!("ls", "--json", "tiny");
|
||||
|
@ -438,7 +438,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_ls_parseable() {
|
||||
let _ = remove_all(dirs::INSTALLS.as_path());
|
||||
let _ = remove_all(*dirs::INSTALLS);
|
||||
assert_cli!("install");
|
||||
assert_cli_snapshot!("ls", "--parseable", @r###"
|
||||
dummy ref:master
|
||||
|
|
|
@ -53,7 +53,7 @@ impl PluginsLink {
|
|||
));
|
||||
}
|
||||
}
|
||||
file::create_dir_all(&*dirs::PLUGINS)?;
|
||||
file::create_dir_all(*dirs::PLUGINS)?;
|
||||
make_symlink(&path, &symlink)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ pub static CONFIG: Lazy<&Path> = Lazy::new(|| &env::MISE_CONFIG_DIR);
|
|||
pub static STATE: Lazy<&Path> = Lazy::new(|| &env::MISE_STATE_DIR);
|
||||
pub static SYSTEM: Lazy<&Path> = Lazy::new(|| &env::MISE_SYSTEM_DIR);
|
||||
|
||||
pub static PLUGINS: Lazy<PathBuf> = Lazy::new(|| DATA.join("plugins"));
|
||||
pub static DOWNLOADS: Lazy<PathBuf> = Lazy::new(|| DATA.join("downloads"));
|
||||
pub static INSTALLS: Lazy<PathBuf> = Lazy::new(|| DATA.join("installs"));
|
||||
pub static SHIMS: Lazy<PathBuf> = Lazy::new(|| DATA.join("shims"));
|
||||
pub static PLUGINS: Lazy<&Path> = Lazy::new(|| &env::MISE_PLUGINS_DIR);
|
||||
pub static DOWNLOADS: Lazy<&Path> = Lazy::new(|| &env::MISE_DOWNLOADS_DIR);
|
||||
pub static INSTALLS: Lazy<&Path> = Lazy::new(|| &env::MISE_INSTALLS_DIR);
|
||||
pub static SHIMS: Lazy<&Path> = Lazy::new(|| &env::MISE_SHIMS_DIR);
|
||||
|
||||
pub static TRACKED_CONFIGS: Lazy<PathBuf> = Lazy::new(|| STATE.join("tracked-configs"));
|
||||
pub static TRUSTED_CONFIGS: Lazy<PathBuf> = Lazy::new(|| STATE.join("trusted-configs"));
|
||||
|
|
10
src/env.rs
10
src/env.rs
|
@ -49,6 +49,16 @@ pub static MISE_TMP_DIR: Lazy<PathBuf> =
|
|||
pub static MISE_SYSTEM_DIR: Lazy<PathBuf> =
|
||||
Lazy::new(|| var_path("MISE_SYSTEM_DIR").unwrap_or_else(|| PathBuf::from("/etc/mise")));
|
||||
|
||||
// data subdirs
|
||||
pub static MISE_INSTALLS_DIR: Lazy<PathBuf> =
|
||||
Lazy::new(|| var_path("MISE_INSTALLS_DIR").unwrap_or_else(|| MISE_DATA_DIR.join("installs")));
|
||||
pub static MISE_DOWNLOADS_DIR: Lazy<PathBuf> =
|
||||
Lazy::new(|| var_path("MISE_DOWNLOADS_DIR").unwrap_or_else(|| MISE_DATA_DIR.join("downloads")));
|
||||
pub static MISE_PLUGINS_DIR: Lazy<PathBuf> =
|
||||
Lazy::new(|| var_path("MISE_PLUGINS_DIR").unwrap_or_else(|| MISE_DATA_DIR.join("plugins")));
|
||||
pub static MISE_SHIMS_DIR: Lazy<PathBuf> =
|
||||
Lazy::new(|| var_path("MISE_SHIMS_DIR").unwrap_or_else(|| MISE_DATA_DIR.join("shims")));
|
||||
|
||||
pub static MISE_DEFAULT_TOOL_VERSIONS_FILENAME: Lazy<String> = Lazy::new(|| {
|
||||
var("MISE_DEFAULT_TOOL_VERSIONS_FILENAME").unwrap_or_else(|_| ".tool-versions".into())
|
||||
});
|
||||
|
|
|
@ -31,11 +31,19 @@ impl PathEnv {
|
|||
}
|
||||
|
||||
pub fn to_vec(&self) -> Vec<PathBuf> {
|
||||
let mut paths = self.pre.iter().chain(self.mise.iter()).collect_vec();
|
||||
let mut paths = self
|
||||
.pre
|
||||
.iter()
|
||||
.chain(self.mise.iter())
|
||||
.map(|p| p.to_path_buf())
|
||||
.collect_vec();
|
||||
if self.seen_shims {
|
||||
paths.push(&dirs::SHIMS);
|
||||
paths.push(dirs::SHIMS.to_path_buf())
|
||||
}
|
||||
paths.into_iter().chain(self.post.iter()).cloned().collect()
|
||||
paths
|
||||
.into_iter()
|
||||
.chain(self.post.iter().map(|p| p.to_path_buf()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn join(&self) -> OsString {
|
||||
|
|
|
@ -417,10 +417,10 @@ fn build_script_man(name: &str, plugin_path: &Path) -> ScriptManager {
|
|||
.with_env("ASDF_PLUGIN_PATH", plugin_path_s.clone())
|
||||
.with_env("RTX_PLUGIN_PATH", plugin_path_s.clone())
|
||||
.with_env("RTX_PLUGIN_NAME", name.to_string())
|
||||
.with_env("RTX_SHIMS_DIR", &*dirs::SHIMS)
|
||||
.with_env("RTX_SHIMS_DIR", *dirs::SHIMS)
|
||||
.with_env("MISE_PLUGIN_NAME", name.to_string())
|
||||
.with_env("MISE_PLUGIN_PATH", plugin_path)
|
||||
.with_env("MISE_SHIMS_DIR", &*dirs::SHIMS)
|
||||
.with_env("MISE_SHIMS_DIR", *dirs::SHIMS)
|
||||
}
|
||||
|
||||
impl Eq for ExternalPlugin {}
|
||||
|
|
|
@ -71,7 +71,7 @@ fn which_shim(bin_name: &str) -> Result<PathBuf> {
|
|||
// fallback for "system"
|
||||
for path in &*env::PATH {
|
||||
if fs::canonicalize(path).unwrap_or_default()
|
||||
== fs::canonicalize(&*dirs::SHIMS).unwrap_or_default()
|
||||
== fs::canonicalize(*dirs::SHIMS).unwrap_or_default()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ pub fn reshim(ts: &Toolset) -> Result<()> {
|
|||
|
||||
let mise_bin = file::which("mise").unwrap_or(env::MISE_BIN.clone());
|
||||
|
||||
create_dir_all(&*dirs::SHIMS)?;
|
||||
create_dir_all(*dirs::SHIMS)?;
|
||||
|
||||
let (shims_to_add, shims_to_remove) = get_shim_diffs(&mise_bin, ts)?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue