diff --git a/src/build/mod.rs b/src/build/mod.rs index 9c34e7ebd..d509ecebb 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -12,10 +12,22 @@ use std::process::Command; pub fn build_target(target: &Target) -> Result { let target_type = &target.target_type; match target_type { - TargetType::JavaScript => { - let msg = "JavaScript project found. Skipping unnecessary build!".to_string(); - Ok(msg) - } + TargetType::JavaScript => match &target.bundle_config { + None => { + let msg = "JavaScript project found. Skipping unnecessary build!".to_string(); + Ok(msg) + } + Some(config) => { + if config.build_command().spawn()?.wait()?.success() { + Ok(String::from("Build completed successfully!")) + } else { + Err(failure::format_err!( + "Command `{:?}` exited with non-zero exit code!", + config.build_command() + )) + } + } + }, TargetType::Rust => { let _ = which::which("rustc").map_err(|e| { failure::format_err!( @@ -45,21 +57,6 @@ pub fn build_target(target: &Target) -> Result { } Err(e) => Err(e), }, - - TargetType::Bundler => match &target.bundle_config { - None => Err(failure::err_msg("Please specify bundler options!")), - Some(config) => { - if config.build_command().spawn()?.wait()?.success() { - let input = &config.output_dir()?; - Ok(String::from("ok")) - } else { - Err(failure::format_err!( - "Command `{:?}` exited with non-zero exit code!", - config.build_command() - )) - } - } - }, } } diff --git a/src/settings/toml/target_type.rs b/src/settings/toml/target_type.rs index 183407657..ed197a045 100644 --- a/src/settings/toml/target_type.rs +++ b/src/settings/toml/target_type.rs @@ -9,7 +9,6 @@ pub enum TargetType { JavaScript, Rust, Webpack, - Bundler, } impl Default for TargetType { @@ -24,7 +23,6 @@ impl fmt::Display for TargetType { TargetType::JavaScript => "js", TargetType::Rust => "rust", TargetType::Webpack => "webpack", - TargetType::Bundler => "bundler", }; write!(f, "{}", printable) } @@ -38,7 +36,6 @@ impl FromStr for TargetType { "javascript" => Ok(TargetType::JavaScript), "rust" => Ok(TargetType::Rust), "webpack" => Ok(TargetType::Webpack), - "bundler" => Ok(TargetType::Bundler), _ => failure::bail!("{} is not a valid wrangler build type!", s), } } diff --git a/src/upload/form/mod.rs b/src/upload/form/mod.rs index 33df9c87d..09de2c0e8 100644 --- a/src/upload/form/mod.rs +++ b/src/upload/form/mod.rs @@ -113,7 +113,6 @@ pub fn build( build_form(&assets, session_config) } - TargetType::Bundler => todo!(), } } diff --git a/src/watch/mod.rs b/src/watch/mod.rs index 3bd9dff03..929186228 100644 --- a/src/watch/mod.rs +++ b/src/watch/mod.rs @@ -3,7 +3,7 @@ use ignore::overrides::OverrideBuilder; use ignore::WalkBuilder; pub use watcher::wait_for_changes; -use crate::build::{build_target, command}; +use crate::build::command; use crate::settings::toml::{Target, TargetType}; use crate::terminal::message::{Message, StdOut}; use crate::wranglerjs; @@ -103,34 +103,35 @@ pub fn watch_and_build( } TargetType::Webpack => { wranglerjs::run_build_and_watch(target, tx)?; - } - TargetType::Bundler => { - let (tx, rx) = mpsc::channel::(); - let mut watcher = notify::watcher(tx, COOLDOWN_PERIOD)?; - - watcher.watch( - &target.bundle_config.clone().unwrap().src_dir()?, - notify::RecursiveMode::Recursive, - )?; - - let mut is_first = true; - - loop { - match rx.recv() { - Ok(_) => { - if is_first { - is_first = false; - StdOut::info("Ignoring stale first change"); - continue; - } else { - let output = build_target(target)?; - StdOut::success(&format!("{}\nUploading...", output)); - } - } - Err(_) => StdOut::user_error("Something went wrong while watching."), - } - } - } + } /* + TargetType::Bundler => { + let (tx, rx) = mpsc::channel::(); + let mut watcher = notify::watcher(tx, COOLDOWN_PERIOD)?; + + watcher.watch( + &target.bundle_config.clone().unwrap().src_dir()?, + notify::RecursiveMode::Recursive, + )?; + + let mut is_first = true; + + loop { + match rx.recv() { + Ok(_) => { + if is_first { + is_first = false; + StdOut::info("Ignoring stale first change"); + continue; + } else { + let output = build_target(target)?; + StdOut::success(&format!("{}\nUploading...", output)); + } + } + Err(_) => StdOut::user_error("Something went wrong while watching."), + } + } + } + */ } Ok(())