Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions apps/oxfmt/src/cli/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,29 @@ impl FormatRunner {

// Count the processed files
let total_target_files_count = changed_paths.len() + unchanged_count + error_count;
let print_stats = |stdout| {
let elapsed_ms = start_time.elapsed().as_millis();
let print_stats = |stdout, stderr| {
utils::print_and_flush(
stdout,
&format!(
"Finished in {elapsed_ms}ms on {total_target_files_count} files using {num_of_threads} threads.\n",
"Finished in {}ms on {total_target_files_count} files using {num_of_threads} threads.\n",
start_time.elapsed().as_millis()
),
);
// Config stats: only show when no config is found
if oxfmtrc_path.is_none() && editorconfig_path.is_none() {
let hint = "No config found, using defaults. Please add `.oxfmtrc.json` or try `oxfmt --init` if needed.\n";
#[cfg(not(feature = "napi"))]
let hint =
"No config found, using defaults. Please add `.oxfmtrc.json` if needed.\n";
utils::print_and_flush(stderr, hint);
}
};

// Check if no files were found
if total_target_files_count == 0 {
if runtime_options.no_error_on_unmatched_pattern {
utils::print_and_flush(stderr, "No files found matching the given patterns.\n");
print_stats(stdout);
print_stats(stdout, stderr);
return CliRunResult::None;
}

Expand All @@ -231,7 +239,7 @@ impl FormatRunner {
// `--check` outputs friendly summary
(OutputMode::Check, 0) => {
utils::print_and_flush(stdout, "All matched files use the correct format.\n");
print_stats(stdout);
print_stats(stdout, stderr);
CliRunResult::FormatSucceeded
}
(OutputMode::Check, changed_count) => {
Expand All @@ -242,7 +250,7 @@ impl FormatRunner {
"Format issues found in above {changed_count} files. Run without `--check` to fix.\n",
),
);
print_stats(stdout);
print_stats(stdout, stderr);
CliRunResult::FormatMismatch
}
// Default (write) outputs only stats
Expand All @@ -252,7 +260,7 @@ impl FormatRunner {
changed_count, 0,
"In write mode, changed_count should not be counted"
);
print_stats(stdout);
print_stats(stdout, stderr);
CliRunResult::FormatSucceeded
}
}
Expand Down
Loading