MCPcopy Create free account
hub / github.com/hashintel/hash / load_env

Function load_env

libs/@local/graph/postgres-store/src/lib.rs:48–74  ·  view source on GitHub ↗

Loads the environment variables from the repository root .env files.

(environment: impl Into<Option<Environment>>)

Source from the content-addressed store, hash-verified

46
47/// Loads the environment variables from the repository root .env files.
48pub fn load_env(environment: impl Into<Option<Environment>>) -> Vec<PathBuf> {
49 let environment = environment.into().unwrap_or(if cfg!(test) {
50 Environment::Test
51 } else if cfg!(debug_assertions) {
52 Environment::Development
53 } else {
54 Environment::Production
55 });
56
57 let environment_path = format!(".env.{environment}");
58 let environment_path_local = format!(".env.{environment}.local");
59
60 [
61 ".env.local",
62 &environment_path_local,
63 &environment_path,
64 ".env",
65 ]
66 .into_iter()
67 .filter_map(|path| {
68 dotenv_flow::from_filename(
69 Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../../..")).join(path),
70 )
71 .ok()
72 })
73 .collect()
74}

Callers 6

mainFunction · 0.85
new_with_settingsMethod · 0.85
newMethod · 0.85
bench_json_queriesFunction · 0.85
setup_dbMethod · 0.85
newMethod · 0.85

Calls 3

collectMethod · 0.80
into_iterMethod · 0.45
joinMethod · 0.45

Tested by 1

newMethod · 0.68