Skip to content

Commit

Permalink
node: default PATH to current PATH when compiling (#1107)
Browse files Browse the repository at this point in the history
* node: default PATH to current PATH when compiling

Fixes #1106

* Restyled by rustfmt (#1108)

Co-authored-by: Restyled.io <[email protected]>

---------

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent f13c6bf commit a3676e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ impl<'a> CmdLineRunner<'a> {

pub fn prepend_path_env(&mut self, path: PathBuf) -> &mut Self {
let k: OsString = "PATH".into();
let mut paths = env::split_paths(self.get_env(&k).unwrap()).collect::<Vec<_>>();
let existing = self
.get_env(&k)
.map(|c| c.to_owned())
.unwrap_or_else(|| env::var_os("PATH").unwrap());
let mut paths = env::split_paths(&existing).collect::<Vec<_>>();
paths.insert(0, path);
self.cmd.env("PATH", env::join_paths(paths).unwrap());
self
Expand Down

0 comments on commit a3676e4

Please sign in to comment.