Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Add "None"s for bundle config so rustc stops complaining
Browse files Browse the repository at this point in the history
  • Loading branch information
caass committed Sep 28, 2020
1 parent 7dafd73 commit e5b4049
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/commands/kv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ mod tests {
webpack_config: None,
site: None,
vars: None,
bundle_config: None,
};
assert!(kv::get_namespace_id(&target_with_dup_kv_bindings, "").is_err());
}
Expand Down
3 changes: 3 additions & 0 deletions src/settings/toml/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
use serde_with::rust::string_empty_as_none;

use crate::commands::{validate_worker_name, DEFAULT_CONFIG_PATH};
use crate::settings::toml::bundle::Bundle;
use crate::settings::toml::deploy_config::{DeployConfig, RouteConfig};
use crate::settings::toml::dev::Dev;
use crate::settings::toml::environment::Environment;
Expand All @@ -34,6 +35,7 @@ pub struct Manifest {
#[serde(default, with = "string_empty_as_none")]
pub zone_id: Option<String>,
pub webpack_config: Option<String>,
pub bundle_config: Option<Bundle>,
pub private: Option<bool>,
// TODO: maybe one day, serde toml support will allow us to serialize sites
// as a TOML inline table (this would prevent confusion with environments too!)
Expand Down Expand Up @@ -221,6 +223,7 @@ impl Manifest {
kv_namespaces: get_namespaces(self.kv_namespaces.clone(), preview)?, // MUST NOT inherit
site: self.site.clone(), // MUST NOT inherit
vars: self.vars.clone(), // MAY inherit,
bundle_config: self.bundle_config.clone(), // lol idk what this inherit stuff means
};

let environment = self.get_environment(environment_name)?;
Expand Down
1 change: 1 addition & 0 deletions src/sites/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ mod tests {
target_type: TargetType::JavaScript,
webpack_config: None,
site: Some(site),
bundle_config: None,
vars: None,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/upload/form/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub fn build(

build_form(&assets, session_config)
}
TargetType::Bundler => todo!(),
}
}

Expand Down
29 changes: 28 additions & 1 deletion src/watch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ignore::overrides::OverrideBuilder;
use ignore::WalkBuilder;
pub use watcher::wait_for_changes;

use crate::build::command;
use crate::build::{build_target, command};
use crate::settings::toml::{Target, TargetType};
use crate::terminal::message::{Message, StdOut};
use crate::wranglerjs;
Expand Down Expand Up @@ -104,6 +104,33 @@ pub fn watch_and_build(
TargetType::Webpack => {
wranglerjs::run_build_and_watch(target, tx)?;
}
TargetType::Bundler => {
let (tx, rx) = mpsc::channel::<notify::DebouncedEvent>();
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(())
Expand Down

0 comments on commit e5b4049

Please sign in to comment.