pass build.npm from bootstrap to tidy and use it for npm install

This commit is contained in:
binarycat 2025-07-22 12:21:14 -05:00
parent 35487a2e7c
commit 2d1fccd7a1
4 changed files with 14 additions and 4 deletions

View file

@ -1113,6 +1113,12 @@ impl Step for Tidy {
8 * std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
});
cmd.arg(jobs.to_string());
// pass the path to the npm command used for installing js deps.
if let Some(npm) = &builder.config.npm {
cmd.arg(npm);
} else {
cmd.arg("npm");
}
if builder.is_verbose() {
cmd.arg("--verbose");
}

View file

@ -50,6 +50,7 @@ pub fn check(
ci_info: &CiInfo,
librustdoc_path: &Path,
tools_path: &Path,
npm: &Path,
bless: bool,
extra_checks: Option<&str>,
pos_args: &[String],
@ -61,6 +62,7 @@ pub fn check(
ci_info,
librustdoc_path,
tools_path,
npm,
bless,
extra_checks,
pos_args,
@ -75,6 +77,7 @@ fn check_impl(
ci_info: &CiInfo,
librustdoc_path: &Path,
tools_path: &Path,
npm: &Path,
bless: bool,
extra_checks: Option<&str>,
pos_args: &[String],
@ -293,7 +296,7 @@ fn check_impl(
}
if js_lint || js_typecheck {
rustdoc_js::npm_install(root_path, outdir)?;
rustdoc_js::npm_install(root_path, outdir, npm)?;
}
if js_lint {

View file

@ -23,9 +23,8 @@ fn spawn_cmd(cmd: &mut Command) -> Result<Child, io::Error> {
}
/// install all js dependencies from package.json.
pub(super) fn npm_install(root_path: &Path, outdir: &Path) -> Result<(), super::Error> {
// FIXME(lolbinarycat): make this obey build.npm bootstrap option
npm::install(root_path, outdir, Path::new("npm"))?;
pub(super) fn npm_install(root_path: &Path, outdir: &Path, npm: &Path) -> Result<(), super::Error> {
npm::install(root_path, outdir, npm)?;
Ok(())
}

View file

@ -29,6 +29,7 @@ fn main() {
let concurrency: NonZeroUsize =
FromStr::from_str(&env::args().nth(4).expect("need concurrency"))
.expect("concurrency must be a number");
let npm: PathBuf = env::args_os().nth(5).expect("need name/path of npm command").into();
let root_manifest = root_path.join("Cargo.toml");
let src_path = root_path.join("src");
@ -182,6 +183,7 @@ fn main() {
&ci_info,
&librustdoc_path,
&tools_path,
&npm,
bless,
extra_checks,
pos_args