Skip to content

Commit

Permalink
autoreload by default, change flag to no-autoreload
Browse files Browse the repository at this point in the history
  • Loading branch information
kcking committed Jul 28, 2021
1 parent 5180a88 commit a0f9d16
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/config/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -212,7 +212,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,
Expand Down
6 changes: 3 additions & 3 deletions src/config/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ pub struct RtcServe {
pub proxy_ws: bool,
/// Any proxies configured to run along with the server.
pub proxies: Option<Vec<ConfigOptsProxy>>,
/// 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 {
Expand All @@ -148,7 +148,7 @@ impl RtcServe {
proxy_rewrite: opts.proxy_rewrite,
proxy_ws: opts.proxy_ws,
proxies,
autoreload: opts.autoreload,
no_autoreload: opts.no_autoreload,
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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<State>, stream| async move {
request.state().ws.lock().await.push(stream);
Expand Down

0 comments on commit a0f9d16

Please sign in to comment.