diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-05-01 17:42:13 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-05-01 17:42:22 +0200 |
| commit | bc68d3a14467ef6fcebb003f79c2f4c5ef5dd08e (patch) | |
| tree | 0873414b61913e067e11d82aa5e78a0a6135588d | |
| parent | d2eadb7a94ef8c9deb5137695df33cd1fc5aee92 (diff) | |
| download | rust-bc68d3a14467ef6fcebb003f79c2f4c5ef5dd08e.tar.gz rust-bc68d3a14467ef6fcebb003f79c2f4c5ef5dd08e.zip | |
Improve error output in case `nodejs` or `npm` is not installed for rustdoc-gui test suite
| -rw-r--r-- | src/tools/rustdoc-gui-test/src/config.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/tools/rustdoc-gui-test/src/config.rs b/src/tools/rustdoc-gui-test/src/config.rs index 950e2fa478d..b9d08a0a295 100644 --- a/src/tools/rustdoc-gui-test/src/config.rs +++ b/src/tools/rustdoc-gui-test/src/config.rs @@ -20,8 +20,8 @@ pub(crate) struct Config { impl Config { pub(crate) fn from_args(args: Vec<String>) -> Self { let mut opts = Options::new(); - opts.reqopt("", "nodejs", "absolute path of nodejs", "PATH") - .reqopt("", "npm", "absolute path of npm", "PATH") + opts.optopt("", "nodejs", "absolute path of nodejs", "PATH") + .optopt("", "npm", "absolute path of npm", "PATH") .reqopt("", "out-dir", "output path of doc compilation", "PATH") .reqopt("", "rust-src", "root source of the rust source", "PATH") .reqopt( @@ -47,9 +47,18 @@ impl Config { Err(f) => panic!("{:?}", f), }; + let Some(nodejs) = matches.opt_str("nodejs").map(PathBuf::from) else { + eprintln!("`nodejs` was not provided. If not available, please install it"); + std::process::exit(1); + }; + let Some(npm) = matches.opt_str("npm").map(PathBuf::from) else { + eprintln!("`npm` was not provided. If not available, please install it"); + std::process::exit(1); + }; + Self { - nodejs: matches.opt_str("nodejs").map(PathBuf::from).expect("nodejs isn't available"), - npm: matches.opt_str("npm").map(PathBuf::from).expect("npm isn't available"), + nodejs, + npm, rust_src: matches.opt_str("rust-src").map(PathBuf::from).unwrap(), out_dir: matches.opt_str("out-dir").map(PathBuf::from).unwrap(), initial_cargo: matches.opt_str("initial-cargo").map(PathBuf::from).unwrap(), |
