
This PR adds a REST API to the collab server for searching and downloading extensions. Previously, we had implemented this API in zed.dev directly, but this implementation is better, because we use the collab database to store the download counts for extensions. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Conrad <conrad@zed.dev>
21 lines
664 B
Rust
21 lines
664 B
Rust
use anyhow::anyhow;
|
|
use std::fs;
|
|
|
|
pub fn load_dotenv() -> anyhow::Result<()> {
|
|
let env: toml::map::Map<String, toml::Value> = toml::de::from_str(
|
|
&fs::read_to_string("./crates/collab/.env.toml")
|
|
.map_err(|_| anyhow!("no .env.toml file found"))?,
|
|
)?;
|
|
|
|
for (key, value) in env {
|
|
let value = match value {
|
|
toml::Value::String(value) => value,
|
|
toml::Value::Integer(value) => value.to_string(),
|
|
toml::Value::Float(value) => value.to_string(),
|
|
_ => panic!("unsupported TOML value in .env.toml for key {}", key),
|
|
};
|
|
std::env::set_var(key, value);
|
|
}
|
|
|
|
Ok(())
|
|
}
|