Skip to main content

asimov_env/
paths.rs

1// This is free and unencumbered software released into the public domain.
2
3use super::vars;
4use std::path::PathBuf;
5
6pub fn asimov_root() -> PathBuf {
7    if let Some(asimov_root) = vars::asimov_root() {
8        return asimov_root;
9    }
10
11    #[cfg(unix)]
12    return getenv::home()
13        .map(|p| PathBuf::from(p).join(".asimov"))
14        .expect("ASIMOV_ROOT or HOME environment variables must be set");
15
16    #[cfg(windows)]
17    return getenv::appdata()
18        .map(|p| PathBuf::from(p).join("ASIMOV"))
19        .expect("ASIMOV_ROOT or APPDATA environment variables must be set");
20}
21
22pub fn python_env() -> PathBuf {
23    asimov_root().join("envs/python")
24}
25
26pub fn ruby_env() -> PathBuf {
27    asimov_root().join("envs/ruby")
28}