Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix `.env.toml` paths (#15645)

Marshall Bowers60127f2a8db4
diff --git a/crates/collab/src/bin/dotenv.rs b/crates/collab/src/bin/dotenv.rs
index b2f5af9b391..6cd7c1f2899 100644
--- a/crates/collab/src/bin/dotenv.rs
+++ b/crates/collab/src/bin/dotenv.rs
@@ -1,7 +1,7 @@
use collab::env::get_dotenv_vars;
fn main() -> anyhow::Result<()> {
- for (key, value) in get_dotenv_vars()? {
+ for (key, value) in get_dotenv_vars(".")? {
println!("export {}=\"{}\"", key, value);
}
Ok(())
diff --git a/crates/collab/src/env.rs b/crates/collab/src/env.rs
index f5e316bb4ad..bdbb4819fb4 100644
--- a/crates/collab/src/env.rs
+++ b/crates/collab/src/env.rs
@@ -1,14 +1,17 @@
use anyhow::{anyhow, Result};
use std::fs;
+use std::path::Path;
+
+pub fn get_dotenv_vars(current_dir: impl AsRef<Path>) -> Result<Vec<(String, String)>> {
+ let current_dir = current_dir.as_ref();
-pub fn get_dotenv_vars() -> Result<Vec<(String, String)>> {
let mut vars = Vec::new();
- let env_content = fs::read_to_string("./crates/collab/.env.toml")
+ let env_content = fs::read_to_string(current_dir.join(".env.toml"))
.map_err(|_| anyhow!("no .env.toml file found"))?;
add_vars(env_content, &mut vars)?;
- if let Ok(secret_content) = fs::read_to_string("./crates/collab/.env.secret.toml") {
+ if let Ok(secret_content) = fs::read_to_string(current_dir.join(".env.secret.toml")) {
add_vars(secret_content, &mut vars)?;
}
@@ -16,7 +19,7 @@ pub fn get_dotenv_vars() -> Result<Vec<(String, String)>> {
}
pub fn load_dotenv() -> Result<()> {
- for (key, value) in get_dotenv_vars()? {
+ for (key, value) in get_dotenv_vars("./crates/collab")? {
std::env::set_var(key, value);
}
Ok(())