| use turbo_rcstr::RcStr; | |
| use turbo_tasks::{FxIndexMap, Vc, mark_session_dependent}; | |
| use crate::{EnvMap, GLOBAL_ENV_LOCK, ProcessEnv, sorted_env_vars}; | |
| /// Load the environment variables defined via command line. | |
| pub struct CommandLineProcessEnv; | |
| impl CommandLineProcessEnv { | |
| pub fn new() -> Vc<Self> { | |
| CommandLineProcessEnv.cell() | |
| } | |
| } | |
| /// Clones the current env vars into a FxIndexMap. | |
| fn env_snapshot() -> FxIndexMap<RcStr, RcStr> { | |
| let _lock = GLOBAL_ENV_LOCK.lock().unwrap(); | |
| sorted_env_vars() | |
| } | |
| impl ProcessEnv for CommandLineProcessEnv { | |
| fn read_all(&self) -> Vc<EnvMap> { | |
| mark_session_dependent(); | |
| Vc::cell(env_snapshot()) | |
| } | |
| } | |