Skip to content

Commit 0ddcd3f

Browse files
committed
tidy: put node_modules under build
1 parent f50898d commit 0ddcd3f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,28 @@ use ignore::DirEntry;
1010

1111
use crate::walk::walk_no_read;
1212

13+
fn node_module_bin(name: &str) -> String {
14+
format!("build/node_modules/.bin/{name}")
15+
}
16+
1317
/// install all js dependencies from package.json.
1418
pub(super) fn npm_install() -> Result<(), super::Error> {
15-
// disable a bunch of things we don't want.
16-
// this makes tidy output less noisy, and also significantly improves runtime
17-
// of repeated tidy invokations.
19+
// copy stuff to build/ to make node_modules get put there.
20+
std::fs::copy("package.json", "build/package.json")?;
21+
std::fs::copy("package-lock.json", "build/package-lock.json")?;
22+
1823
let mut cmd = Command::new("npm");
1924
if CiEnv::is_ci() {
2025
// `npm ci` redownloads every time and thus is too slow for local development.
2126
cmd.arg("ci");
2227
} else {
2328
cmd.arg("install");
2429
}
30+
// disable a bunch of things we don't want.
31+
// this makes tidy output less noisy, and also significantly improves runtime
32+
// of repeated tidy invokations.
2533
cmd.args(&["--audit=false", "--save=false", "--fund=false"]);
34+
cmd.current_dir("build");
2635
let mut child = cmd.spawn()?;
2736
match child.wait() {
2837
Ok(exit_status) => {
@@ -48,7 +57,7 @@ fn rustdoc_js_files(librustdoc_path: &Path) -> Vec<PathBuf> {
4857
}
4958

5059
fn run_eslint(args: &[PathBuf], config_folder: PathBuf) -> Result<(), super::Error> {
51-
let mut child = Command::new("node_modules/.bin/eslint")
60+
let mut child = Command::new(node_module_bin("eslint"))
5261
.arg("-c")
5362
.arg(config_folder.join(".eslintrc.js"))
5463
.args(args)
@@ -130,7 +139,7 @@ pub(super) fn lint(
130139

131140
pub(super) fn typecheck(librustdoc_path: &Path) -> Result<(), super::Error> {
132141
// use npx to ensure correct version
133-
let mut child = Command::new("node_modules/.bin/tsc")
142+
let mut child = Command::new(node_module_bin("tsc"))
134143
.arg("-p")
135144
.arg(librustdoc_path.join("html/static/js/tsconfig.json"))
136145
.spawn()?;
@@ -147,7 +156,7 @@ pub(super) fn typecheck(librustdoc_path: &Path) -> Result<(), super::Error> {
147156

148157
pub(super) fn es_check(librustdoc_path: &Path) -> Result<(), super::Error> {
149158
let files_to_check = rustdoc_js_files(librustdoc_path);
150-
let mut cmd = Command::new("node_modules/.bin/es-check");
159+
let mut cmd = Command::new(node_module_bin("es-check"));
151160
cmd.arg("es2019");
152161
for f in files_to_check {
153162
cmd.arg(f);

0 commit comments

Comments
 (0)