From d7a047c6059bdefe4ae4a8cac26d509065093e81 Mon Sep 17 00:00:00 2001 From: Kevin King <4kevinking@gmail.com> Date: Tue, 27 Jul 2021 20:46:32 -0700 Subject: [PATCH] autoreload by default, change flag to no-autoreload --- src/config/models.rs | 8 ++++---- src/config/rt.rs | 6 +++--- src/serve.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/config/models.rs b/src/config/models.rs index 037b0104..86e9dd58 100644 --- a/src/config/models.rs +++ b/src/config/models.rs @@ -61,10 +61,10 @@ pub struct ConfigOptsServe { #[structopt(long = "proxy-ws")] #[serde(default)] pub proxy_ws: bool, - /// Whether to auto-reload the web page when a build completes. - #[structopt(long)] + /// Whether to disable auto-reload of the web page when a build completes. + #[structopt(long = "no-autoreload")] #[serde(default)] - pub autoreload: bool, + pub no_autoreload: bool, } /// Config options for the serve system. @@ -191,7 +191,7 @@ impl ConfigOpts { proxy_backend: cli.proxy_backend, proxy_rewrite: cli.proxy_rewrite, proxy_ws: cli.proxy_ws, - autoreload: cli.autoreload, + no_autoreload: cli.no_autoreload, }; let cfg = ConfigOpts { build: None, diff --git a/src/config/rt.rs b/src/config/rt.rs index ac1eec90..58cbe943 100644 --- a/src/config/rt.rs +++ b/src/config/rt.rs @@ -127,8 +127,8 @@ pub struct RtcServe { pub proxy_ws: bool, /// Any proxies configured to run along with the server. pub proxies: Option>, - /// Whether to auto-reload the web page when a build completes. - pub autoreload: bool, + /// Whether to disable auto-reload of the web page when a build completes. + pub no_autoreload: bool, } impl RtcServe { @@ -144,7 +144,7 @@ impl RtcServe { proxy_rewrite: opts.proxy_rewrite, proxy_ws: opts.proxy_ws, proxies, - autoreload: opts.autoreload, + no_autoreload: opts.no_autoreload, }) } } diff --git a/src/serve.rs b/src/serve.rs index ee1b9157..0417f6c8 100644 --- a/src/serve.rs +++ b/src/serve.rs @@ -50,7 +50,7 @@ impl ServeSystem { } } - if self.cfg.autoreload { + if !self.cfg.no_autoreload { spawn(Self::build_notify_task(self.build_done_rx, websockets)); } @@ -83,13 +83,13 @@ impl ServeSystem { let state = State { index, ws: Default::default(), - inject_reload_script: cfg.autoreload, + inject_reload_script: !cfg.no_autoreload, }; let websockets = state.ws.clone(); // Build app. let mut app = tide::with_state(state); - if cfg.autoreload { + if !cfg.no_autoreload { app.at("/_trunk/ws") .get(WebSocket::new(|request: tide::Request, stream| async move { request.state().ws.lock().await.push(stream);