Use proper npm arguments and clean its inherited env vars

This commit is contained in:
Kirill Bulatov 2023-11-28 18:39:03 +02:00
parent 179ad03ebc
commit 5451db9c96

View file

@ -73,6 +73,7 @@ impl RealNodeRuntime {
let npm_file = node_dir.join("bin/npm"); let npm_file = node_dir.join("bin/npm");
let result = Command::new(&node_binary) let result = Command::new(&node_binary)
.env_clear()
.arg(npm_file) .arg(npm_file)
.arg("--version") .arg("--version")
.stdin(Stdio::null()) .stdin(Stdio::null())
@ -149,6 +150,7 @@ impl NodeRuntime for RealNodeRuntime {
} }
let mut command = Command::new(node_binary); let mut command = Command::new(node_binary);
command.env_clear();
command.env("PATH", env_path); command.env("PATH", env_path);
command.arg(npm_file).arg(subcommand); command.arg(npm_file).arg(subcommand);
command.args(["--cache".into(), installation_path.join("cache")]); command.args(["--cache".into(), installation_path.join("cache")]);
@ -200,11 +202,11 @@ impl NodeRuntime for RealNodeRuntime {
&[ &[
name, name,
"--json", "--json",
"-fetch-retry-mintimeout", "--fetch-retry-mintimeout",
"2000", "2000",
"-fetch-retry-maxtimeout", "--fetch-retry-maxtimeout",
"5000", "5000",
"-fetch-timeout", "--fetch-timeout",
"5000", "5000",
], ],
) )
@ -229,11 +231,11 @@ impl NodeRuntime for RealNodeRuntime {
let mut arguments: Vec<_> = packages.iter().map(|p| p.as_str()).collect(); let mut arguments: Vec<_> = packages.iter().map(|p| p.as_str()).collect();
arguments.extend_from_slice(&[ arguments.extend_from_slice(&[
"-fetch-retry-mintimeout", "--fetch-retry-mintimeout",
"2000", "2000",
"-fetch-retry-maxtimeout", "--fetch-retry-maxtimeout",
"5000", "5000",
"-fetch-timeout", "--fetch-timeout",
"5000", "5000",
]); ]);