diff --git a/crates/tuono/src/app.rs b/crates/tuono/src/app.rs index 1f1bef0b..be569ece 100644 --- a/crates/tuono/src/app.rs +++ b/crates/tuono/src/app.rs @@ -6,6 +6,7 @@ use std::collections::{hash_map::Entry, HashMap}; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; +use std::path::Path; use std::path::PathBuf; use std::process::Child; use std::process::Command; @@ -138,9 +139,18 @@ impl App { } pub fn build_react_prod(&self) { - Command::new(BUILD_JS_SCRIPT) + if !Path::new(BUILD_JS_SCRIPT).exists() { + eprintln!("Failed to find the build script. Please run `npm install`"); + std::process::exit(1); + } + let output = Command::new(BUILD_JS_SCRIPT) .output() .expect("Failed to build the react source"); + if !output.status.success() { + eprintln!("Failed to build the react source"); + eprintln!("Error: {}", String::from_utf8_lossy(&output.stderr)); + std::process::exit(1); + } } pub fn run_rust_server(&self) -> Child { @@ -154,6 +164,10 @@ impl App { } pub fn build_tuono_config(&self) -> Result { + if !Path::new(BUILD_TUONO_CONFIG).exists() { + eprintln!("Failed to find the build script. Please run `npm install`"); + std::process::exit(1); + } Command::new(BUILD_TUONO_CONFIG) .stdin(Stdio::piped()) .stdout(Stdio::piped()) diff --git a/crates/tuono/src/watch.rs b/crates/tuono/src/watch.rs index fc81e834..e2fbf489 100644 --- a/crates/tuono/src/watch.rs +++ b/crates/tuono/src/watch.rs @@ -1,3 +1,4 @@ +use std::path::Path; use std::sync::Arc; use watchexec_supervisor::command::{Command, Program}; @@ -20,6 +21,10 @@ const DEV_WATCH_BIN_SRC: &str = "node_modules/.bin/tuono-dev-watch"; const DEV_SSR_BIN_SRC: &str = "node_modules/.bin/tuono-dev-ssr"; fn watch_react_src() -> Job { + if !Path::new(DEV_SSR_BIN_SRC).exists() { + eprintln!("Failed to find script to run dev watch. Please run `npm install`"); + std::process::exit(1); + } start_job(Arc::new(Command { program: Program::Exec { prog: DEV_WATCH_BIN_SRC.into(), @@ -42,6 +47,10 @@ fn build_rust_src() -> Job { } fn build_react_ssr_src() -> Job { + if !Path::new(DEV_SSR_BIN_SRC).exists() { + eprintln!("Failed to find script to run dev ssr. Please run `npm install`"); + std::process::exit(1); + } start_job(Arc::new(Command { program: Program::Exec { prog: DEV_SSR_BIN_SRC.into(),