Installs required packages and selects toolchain to use. It will prioritize `yarn` over `npm`. # Panic Will panic if none of the toolchains is installed.
()
| 28 | /// # Panic |
| 29 | /// Will panic if none of the toolchains is installed. |
| 30 | fn install_packages() -> &'static str { |
| 31 | let yarn = if_windows("yarn.cmd", "yarn"); |
| 32 | let npm = if_windows("npm.cmd", "npm"); |
| 33 | let npx = if_windows("npx.cmd", "npx"); |
| 34 | |
| 35 | if std::process::Command::new(yarn).arg("install").spawn().is_ok() { |
| 36 | return yarn |
| 37 | } |
| 38 | |
| 39 | match std::process::Command::new(npm).arg("install").spawn() { |
| 40 | Ok(_) => npx, |
| 41 | Err(e) => panic!("ERROR: Npm or Yarn installation is needed.\n{e}"), |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | const fn if_windows(windows: &'static str, unix: &'static str) -> &'static str { |
| 46 | #[cfg(windows)] |