Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/turbo-tasks-env/src/command_line.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::env;

use indexmap::IndexMap;
use turbo_tasks::Vc;

use crate::{EnvMap, ProcessEnv, GLOBAL_ENV_LOCK};
use crate::{sorted_env_vars, EnvMap, ProcessEnv, GLOBAL_ENV_LOCK};

/// Load the environment variables defined via command line.
#[turbo_tasks::value]
Expand All @@ -20,7 +18,7 @@ impl CommandLineProcessEnv {
/// Clones the current env vars into a IndexMap.
fn env_snapshot() -> IndexMap<String, String> {
let _lock = GLOBAL_ENV_LOCK.lock().unwrap();
env::vars().collect::<IndexMap<_, _>>()
sorted_env_vars()
}

#[turbo_tasks::value_impl]
Expand Down
6 changes: 3 additions & 3 deletions crates/turbo-tasks-env/src/dotenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use indexmap::IndexMap;
use turbo_tasks::{ValueToString, Vc};
use turbo_tasks_fs::{FileContent, FileSystemPath};

use crate::{EnvMap, ProcessEnv, GLOBAL_ENV_LOCK};
use crate::{sorted_env_vars, EnvMap, ProcessEnv, GLOBAL_ENV_LOCK};

/// Load the environment variables defined via a dotenv file, with an
/// optional prior state that we can lookup already defined variables
Expand Down Expand Up @@ -47,7 +47,7 @@ impl DotenvProcessEnv {
// Unfortunately, dotenvy only looks up variable references from the global env.
// So we must mutate while we process. Afterwards, we can restore the initial
// state.
let initial = env::vars().collect();
let initial = sorted_env_vars();

restore_env(&initial, &prior, &lock);

Expand All @@ -56,7 +56,7 @@ impl DotenvProcessEnv {
// var, it'll be ignored.
res = dotenv::from_read(f.read()).map(|e| e.load());

vars = env::vars().collect();
vars = sorted_env_vars();
restore_env(&vars, &initial, &lock);
}

Expand Down
6 changes: 6 additions & 0 deletions crates/turbo-tasks-env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ pub trait ProcessEnv {
}
}

pub fn sorted_env_vars() -> IndexMap<String, String> {
let mut vars = env::vars().collect::<IndexMap<_, _>>();
vars.sort_keys();
vars
}

#[turbo_tasks::function]
pub async fn case_insensitive_read(map: Vc<EnvMap>, name: String) -> Result<Vc<Option<String>>> {
Ok(Vc::cell(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.