|
@@ -589,21 +589,10 @@ fn init(
|
|
|
mocha.write_all(template::ts_mocha(&project_name).as_bytes())?;
|
|
|
}
|
|
|
|
|
|
- // Install node modules.
|
|
|
- let yarn_result = std::process::Command::new("yarn")
|
|
|
- .stdout(Stdio::inherit())
|
|
|
- .stderr(Stdio::inherit())
|
|
|
- .output()
|
|
|
- .map_err(|e| anyhow::format_err!("yarn install failed: {}", e.to_string()))?;
|
|
|
+ let yarn_result = install_node_modules("yarn")?;
|
|
|
if !yarn_result.status.success() {
|
|
|
println!("Failed yarn install will attempt to npm install");
|
|
|
- std::process::Command::new("npm")
|
|
|
- .arg("install")
|
|
|
- .stdout(Stdio::inherit())
|
|
|
- .stderr(Stdio::inherit())
|
|
|
- .output()
|
|
|
- .map_err(|e| anyhow::format_err!("npm install failed: {}", e.to_string()))?;
|
|
|
- println!("Failed to install node dependencies")
|
|
|
+ install_node_modules("npm")?;
|
|
|
}
|
|
|
|
|
|
if !no_git {
|
|
@@ -623,6 +612,24 @@ fn init(
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
+fn install_node_modules(cmd: &str) -> Result<std::process::Output> {
|
|
|
+ if cfg!(target_os = "windows") {
|
|
|
+ std::process::Command::new("cmd")
|
|
|
+ .arg(format!("/C {} install", cmd))
|
|
|
+ .stdout(Stdio::inherit())
|
|
|
+ .stderr(Stdio::inherit())
|
|
|
+ .output()
|
|
|
+ .map_err(|e| anyhow::format_err!("{} install failed: {}", cmd, e.to_string()))
|
|
|
+ } else {
|
|
|
+ std::process::Command::new(cmd)
|
|
|
+ .arg("install")
|
|
|
+ .stdout(Stdio::inherit())
|
|
|
+ .stderr(Stdio::inherit())
|
|
|
+ .output()
|
|
|
+ .map_err(|e| anyhow::format_err!("{} install failed: {}", cmd, e.to_string()))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// Creates a new program crate in the `programs/<name>` directory.
|
|
|
fn new(cfg_override: &ConfigOverride, name: String) -> Result<()> {
|
|
|
with_workspace(cfg_override, |cfg| {
|