switch from open to opener

By default, `opener` launches the subprocess without waiting for its
completion, compared to `open` which waits for its completion.

This is helpful in case the `watch` feature is enabled and one of the
following commands `watch | serve --open` is used. If this command would
open the browser, listening for changes would be blocked by the browser.
This commit is contained in:
Johannes Stoelp 2021-09-26 19:55:41 +02:00 committed by Eric Huss
parent a306da3ad7
commit ff4b8e7a8d
3 changed files with 9 additions and 15 deletions

20
Cargo.lock generated
View File

@ -131,9 +131,9 @@ dependencies = [
[[package]] [[package]]
name = "bstr" name = "bstr"
version = "0.2.16" version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"memchr", "memchr",
@ -855,7 +855,7 @@ dependencies = [
"log", "log",
"memchr", "memchr",
"notify", "notify",
"open", "opener",
"predicates", "predicates",
"pretty_assertions", "pretty_assertions",
"pulldown-cmark", "pulldown-cmark",
@ -1052,12 +1052,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "open" name = "opener"
version = "2.0.1" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b46b233de7d83bc167fe43ae2dda3b5b84e80e09cceba581e4decb958a4896bf" checksum = "4ea3ebcd72a54701f56345f16785a6d3ac2df7e986d273eb4395c0b01db17952"
dependencies = [ dependencies = [
"pathdiff", "bstr",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1070,12 +1070,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "pathdiff"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877630b3de15c0b64cc52f659345724fbf6bdad9bd9566699fc53688f3c34a34"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"

View File

@ -24,7 +24,7 @@ handlebars = "4.0"
lazy_static = "1.0" lazy_static = "1.0"
log = "0.4" log = "0.4"
memchr = "2.0" memchr = "2.0"
open = "2.0" opener = "0.5"
pulldown-cmark = "0.7.0" pulldown-cmark = "0.7.0"
regex = "1.0.0" regex = "1.0.0"
serde = "1.0" serde = "1.0"

View File

@ -133,7 +133,7 @@ fn get_book_dir(args: &ArgMatches) -> PathBuf {
fn open<P: AsRef<OsStr>>(path: P) { fn open<P: AsRef<OsStr>>(path: P) {
info!("Opening web browser"); info!("Opening web browser");
if let Err(e) = open::that(path) { if let Err(e) = opener::open(path) {
error!("Error opening web browser: {}", e); error!("Error opening web browser: {}", e);
} }
} }