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
19 changes: 16 additions & 3 deletions apps/oxfmt/src/cli/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,22 @@ impl FormatService {

// Write back if needed
if matches!(self.format_mode, OutputMode::Write) && is_changed {
fs::write(path, code)
.map_err(|_| format!("Failed to write to '{}'", path.to_string_lossy()))
.unwrap();
match fs::write(path, &code) {
Ok(()) => (),
Err(err) => {
let diagnostics = DiagnosticService::wrap_diagnostics(
self.cwd.clone(),
path,
"",
vec![oxc_diagnostics::OxcDiagnostic::error(format!(
"Failed to save '{}': {err}",
path.display()
))],
);
tx_error.send(diagnostics).unwrap();
return;
}
}
}

// Report result
Expand Down
Loading