Get W2.0 building

This commit is contained in:
Félix Saparelli 2022-07-07 22:28:15 +12:00
parent f7953a084a
commit 0c3a7fd9db
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
5 changed files with 34 additions and 72 deletions

49
Cargo.lock generated
View File

@ -340,7 +340,7 @@ dependencies = [
"embed-resource",
"futures",
"insta",
"miette 3.3.0",
"miette",
"mimalloc",
"notify-rust",
"predicates",
@ -384,7 +384,7 @@ dependencies = [
"once_cell",
"strsim",
"termcolor",
"textwrap 0.15.0",
"textwrap",
]
[[package]]
@ -1120,7 +1120,7 @@ dependencies = [
"futures",
"git-config",
"ignore",
"miette 4.7.1",
"miette",
"project-origins",
"thiserror",
"tokio",
@ -1321,46 +1321,23 @@ dependencies = [
[[package]]
name = "miette"
version = "3.3.0"
version = "4.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd2adcfcced5d625bf90a958a82ae5b93231f57f3df1383fee28c9b5096d35ed"
checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c"
dependencies = [
"atty",
"backtrace",
"miette-derive 3.3.0",
"miette-derive",
"once_cell",
"owo-colors",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
"terminal_size",
"textwrap 0.14.2",
"thiserror",
]
[[package]]
name = "miette"
version = "4.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c"
dependencies = [
"miette-derive 4.7.1",
"once_cell",
"textwrap",
"thiserror",
"unicode-width",
]
[[package]]
name = "miette-derive"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c01a8b61312d367ce87956bb686731f87e4c6dd5dbc550e8f06e3c24fb1f67f"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "miette-derive"
version = "4.7.1"
@ -2346,21 +2323,15 @@ checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b"
[[package]]
name = "textwrap"
version = "0.14.2"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
dependencies = [
"smawk",
"unicode-linebreak",
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]]
name = "thiserror"
version = "1.0.31"
@ -2782,7 +2753,7 @@ dependencies = [
"futures",
"ignore-files",
"libc",
"miette 4.7.1",
"miette",
"notify",
"once_cell",
"project-origins",

View File

@ -27,7 +27,7 @@ name = "cargo-watch"
console-subscriber = { version = "0.1.0", optional = true }
dunce = "1.0.2"
futures = "0.3.17"
miette = { version = "3.2.0", features = ["fancy"] }
miette = { version = "4.7.1", features = ["fancy-no-backtrace"] }
# shell-escape = "0.1.5"
tracing = "0.1.26"
watchexec = "2.0.0-pre.6"

View File

@ -9,12 +9,7 @@ pub fn init(_args: &Args) -> Result<InitConfig> {
let mut config = InitConfig::default();
config.on_error(SyncFnHandler::from(
|data| -> std::result::Result<(), Infallible> {
if cfg!(debug_assertions) {
eprintln!("[[{:?}]]", data);
} else {
eprintln!("[[{}]]", data);
}
eprintln!("[[{:?}]]", data);
Ok(())
},
));

View File

@ -1,4 +1,4 @@
use std::{convert::Infallible, time::Duration};
use std::{convert::Infallible, time::Duration, env};
use miette::{IntoDiagnostic, Report, Result};
use watchexec::{
@ -52,19 +52,19 @@ pub fn runtime(args: &Args) -> Result<RuntimeConfig> {
// config.command_grouped(args.process_group);
config.command_shell(if let Some(s) = &args.shell {
if s.eq_ignore_ascii_case("powershell") {
Shell::Powershell
} else if s.eq_ignore_ascii_case("none") {
Shell::None
} else if s.eq_ignore_ascii_case("cmd") {
cmd_shell(s.into())
} else {
Shell::Unix(s.into())
}
} else {
default_shell()
});
// config.command_shell(if let Some(s) = &args.shell {
// if s.eq_ignore_ascii_case("powershell") {
// Shell::Powershell
// } else if s.eq_ignore_ascii_case("none") {
// Shell::None
// } else if s.eq_ignore_ascii_case("cmd") {
// cmd_shell(s.into())
// } else {
// Shell::Unix(s.into())
// }
// } else {
// default_shell()
// });
let clear = args.clear;
let notif = args.notif;
@ -209,17 +209,13 @@ pub fn runtime(args: &Args) -> Result<RuntimeConfig> {
config.on_post_spawn(SyncFnHandler::from(move |postspawn: PostSpawn| {
#[cfg(not(target_os = "freebsd"))]
if notif {
Notification::new()
.summary("Cargo Watch: change detected")
.body(&format!("Running `{}`", postspawn.command.join(" ")))
.show()
.map(drop)
.unwrap_or_else(|err| {
eprintln!("[[Failed to send desktop notification: {}]]", err);
});
Notification::new()
.summary("Cargo Watch: change detected")
.body(&format!("Running `{}`", postspawn.command))
.show()?;
}
Ok::<(), Infallible>(())
Ok::<(), notify_rust::error::Error>(())
}));
Ok(config)
@ -232,7 +228,7 @@ fn default_shell() -> Shell {
#[cfg(not(windows))]
fn default_shell() -> Shell {
Shell::default()
Shell::Unix(env::var("SHELL").unwrap_or_else(|_| String::from("sh")))
}
// because Shell::Cmd is only on windows

View File

@ -1,7 +1,7 @@
use std::env::var;
use miette::{IntoDiagnostic, Result};
use watchexec::{event::Event, Watchexec};
use watchexec::{event::{Event, Priority}, Watchexec};
mod args;
mod config;
@ -51,7 +51,7 @@ async fn main() -> Result<()> {
let wx = Watchexec::new(init, runtime)?;
if !args.postpone {
wx.send_event(Event::default()).await?;
wx.send_event(Event::default(), Priority::Urgent).await?;
}
wx.main().await.into_diagnostic()??;