Write a JSON value to a file with pretty formatting. Creates a backup, writes atomically, and restores on failure.
(path: &Path, value: &serde_json::Value)
| 712 | /// Write a JSON value to a file with pretty formatting. |
| 713 | /// Creates a backup, writes atomically, and restores on failure. |
| 714 | pub fn write_json_file(path: &Path, value: &serde_json::Value) -> Result<()> { |
| 715 | let backup = backup_config_file(path)?; |
| 716 | safe_write_json_file(path, value, backup.as_deref())?; |
| 717 | eprintln!("\x1b[32m✔\x1b[0m Wrote {}", path.display()); |
| 718 | Ok(()) |
| 719 | } |
| 720 | |
| 721 | /// Best-effort "back up and write" for uninstall paths. |
| 722 | /// |