From 3f28c3faeb211e0b2c8f515013e24042e1547772 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Sat, 5 Sep 2026 08:11:34 -0400 Subject: [PATCH 1/2] new OsedaRun error --- src/config.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 37417bf..42174bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,6 +16,8 @@ use crate::license::License; use crate::tags::DefinedTag; use crate::{github, license}; +pub const CONFIG_FILE_NAME: &str = "oseda-config.json"; + pub fn read_config_file>( path: P, ) -> Result { @@ -50,7 +52,7 @@ pub fn read_and_validate_config() -> Result { OsedaCheckError::DirectoryNameMismatch("Could not get path of working directory".to_owned()) })?; - let config_path = path.join("oseda-config.json"); + let config_path = path.join(CONFIG_FILE_NAME); let conf = read_config_file(config_path)?; From 6dfd94384fa64ec4afc2c24d26562abf63e61fa4 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Sat, 5 Sep 2026 08:11:43 -0400 Subject: [PATCH 2/2] check for cwd as project --- src/cmd/run.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cmd/run.rs b/src/cmd/run.rs index a059aff..de5d977 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -1,17 +1,17 @@ use std::{ - process::Command, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - time::Duration, + path::Path, process::Command, sync::{ + Arc, atomic::{AtomicBool, Ordering} + }, time::Duration }; +use crate::config::{self}; + /// More in depth errors that could cause a project not to run #[derive(Debug)] pub enum OsedaRunError { BuildError(String), ServeError(String), + NotOsedaProjectError(String), } impl std::error::Error for OsedaRunError {} @@ -20,6 +20,7 @@ impl std::fmt::Display for OsedaRunError { match self { Self::BuildError(msg) => write!(f, "Oseda Build Error: {}", msg), Self::ServeError(msg) => write!(f, "Oseda Serve Error: {}", msg), + Self::NotOsedaProjectError(msg) => write!(f, "Current working directory is not an Oseda project: {}", msg) } } } @@ -39,8 +40,16 @@ pub fn run() -> Result<(), OsedaRunError> { run_with_shutdown(Arc::new(AtomicBool::new(false))) } +pub fn is_cwd_oseda_project() -> bool { + Path::new(config::CONFIG_FILE_NAME).try_exists().is_ok_and(|exists| exists) +} + pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunError> { // command run failure and command status are considered different, handled accordingly + if !is_cwd_oseda_project(){ + return Err(OsedaRunError::NotOsedaProjectError("oseda-config.json not found".to_string())); + } + match Command::new("npx").arg("vite").arg("build").status() { Ok(status) => { if !status.success() {