Skip to content

Commit

Permalink
Improve file watching to process only changed content
Browse files Browse the repository at this point in the history
  • Loading branch information
jeparlefrancais committed Dec 11, 2024
1 parent e72e8f2 commit 12494cb
Show file tree
Hide file tree
Showing 22 changed files with 1,023 additions and 623 deletions.
246 changes: 112 additions & 134 deletions Cargo.lock

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@ path = "src/bin.rs"
tracing = ["dep:tracing"]

[dependencies]
anstyle = "1.0.6"
clap = { version = "4.5.3", features = ["derive"] }
anstyle = "1.0.10"
clap = { version = "4.5.23", features = ["derive"] }
durationfmt = "0.1.1"
elsa = "1.10.0"
env_logger = "0.11.3"
env_logger = "0.11.5"
full_moon = { version = "1.0.0", features = ["roblox"] }
json5 = "0.4.1"
log = "0.4.21"
pathdiff = "0.2.1"
regex = "1.10.4"
log = "0.4.22"
pathdiff = "0.2.3"
petgraph = "0.6.5"
regex = "1.11.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.114"
serde_json = "1.0.133"
serde_yaml = "0.9.32"
toml = "0.8.11"
toml = "0.8.19"
tracing = { version = "0.1", optional = true }
wax = "0.5.0"
xxhash-rust = { version = "0.8.12", features = ["xxh3"] }

[dev-dependencies]
assert_cmd = "2.0.14"
assert_cmd = "2.0.16"
criterion = { version = "0.5.1", features = ["html_reports"] }
include_dir = "0.7.3"
include_dir = "0.7.4"
insta = { version = "1.36.1", features = ["json", "filters"] }
paste = "1.0.14"
pretty_assertions = "1.4.0"
paste = "1.0.15"
pretty_assertions = "1.4.1"
rand = "0.8.5"
rand_distr = "0.4.3"
serde_bytes = "0.11.14"
tempfile = "3.10.1"
serde_bytes = "0.11.15"
tempfile = "3.14.0"
tracing-subscriber = "0.3.18"
tracing-tracy = "0.11.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
web-time = "1.1.0"
# node-sys = "0.4.2"
# web-sys = { version = "0.3.72", features = ["Window", "Performance"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ctrlc = { version = "3.4.4", features = ["termination"] }
notify = "6.1.1"
notify-debouncer-mini = "0.4.1"
ctrlc = { version = "3.4.5", features = ["termination"] }
notify = "7.0.0"
notify-debouncer-full = "0.4.0"

# This is needed because when runnin `cargo test`, the library and its
# dependencies are build with the `dev` profile. To make sure full_moon
Expand Down
1 change: 1 addition & 0 deletions benches/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ macro_rules! generate_bench {
criterion::black_box(&resources),
criterion::black_box($options),
)
.unwrap()
.result()
.unwrap()
})
Expand Down
62 changes: 32 additions & 30 deletions src/cli/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,50 @@ pub fn run(options: &Options, _global: &GlobalOptions) -> CommandResult {

let process_start_time = Instant::now();

let result = darklua_core::process(&resources, process_options);
let result = darklua_core::process(&resources, process_options).map_err(|err| {
log::error!("{}", err);
CliError::new(1)
})?;

let process_duration = durationfmt::to_string(process_start_time.elapsed());

let success_count = result.success_count();

match result.result() {
Ok(()) => {
println!(
let errors = result.collect_errors();

if errors.is_empty() {
println!(
"successfully minified {} file{} (in {})",
success_count,
maybe_plural(success_count),
process_duration
);
Ok(())
} else {
let error_count = errors.len();

if success_count > 0 {
eprintln!(
"successfully minified {} file{} (in {})",
success_count,
maybe_plural(success_count),
process_duration
);
Ok(())
eprintln!(
"But {} error{} happened:",
error_count,
maybe_plural(error_count)
);
} else {
eprintln!(
"{} error{} happened:",
error_count,
maybe_plural(error_count)
);
}
Err(errors) => {
let error_count = errors.len();

if success_count > 0 {
eprintln!(
"successfully minified {} file{} (in {})",
success_count,
maybe_plural(success_count),
process_duration
);
eprintln!(
"But {} error{} happened:",
error_count,
maybe_plural(error_count)
);
} else {
eprintln!(
"{} error{} happened:",
error_count,
maybe_plural(error_count)
);
}

errors.iter().for_each(|error| eprintln!("-> {}", error));
errors.iter().for_each(|error| eprintln!("-> {}", error));

Err(CliError::new(1))
}
Err(CliError::new(1))
}
}
Loading

0 comments on commit 12494cb

Please sign in to comment.