diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-03-30 10:43:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 10:43:16 -0400 |
commit | e0429e2ad641e9207e00838de209ce33b3562f70 (patch) | |
tree | 496c38dadb79c4dc9ae4eea755e2ac6a65440ad4 /test_util/src/builders.rs | |
parent | 3deade4b14de809f67ed0471f8e91c91b25fedcc (diff) |
fix(repl): improve package.json support (#18497)
1. Fixes a cosmetic issue in the repl where it would display lsp warning
messages.
2. Lazily loads dependencies from the package.json on use.
3. Supports using bare specifiers from package.json in the REPL.
Closes #17929
Closes #18494
Diffstat (limited to 'test_util/src/builders.rs')
-rw-r--r-- | test_util/src/builders.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/test_util/src/builders.rs b/test_util/src/builders.rs index 84befb57a..4997dac2c 100644 --- a/test_util/src/builders.rs +++ b/test_util/src/builders.rs @@ -312,6 +312,14 @@ impl TestCommandBuilder { .collect::<Vec<_>>() } + fn build_envs(&self) -> HashMap<String, String> { + let mut envs = self.context.envs.clone(); + for (key, value) in &self.envs { + envs.insert(key.to_string(), value.to_string()); + } + envs + } + pub fn with_pty(&self, mut action: impl FnMut(Pty)) { if !Pty::is_supported() { return; @@ -319,11 +327,20 @@ impl TestCommandBuilder { let args = self.build_args(); let args = args.iter().map(|s| s.as_str()).collect::<Vec<_>>(); - let mut envs = self.envs.clone(); + let mut envs = self.build_envs(); if !envs.contains_key("NO_COLOR") { // set this by default for pty tests envs.insert("NO_COLOR".to_string(), "1".to_string()); } + + // note(dsherret): for some reason I need to inject the current + // environment here for the pty tests or else I get dns errors + if !self.env_clear { + for (key, value) in std::env::vars() { + envs.entry(key).or_insert(value); + } + } + action(Pty::new( &self.build_command_path(), &args, @@ -361,13 +378,7 @@ impl TestCommandBuilder { command.env_clear(); } command.env("DENO_DIR", self.context.deno_dir.path()); - command.envs({ - let mut envs = self.context.envs.clone(); - for (key, value) in &self.envs { - envs.insert(key.to_string(), value.to_string()); - } - envs - }); + command.envs(self.build_envs()); command.current_dir(cwd); command.stdin(Stdio::piped()); |