From acb0aedb92bbf4e685298da80c07b604e8583757 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 23 Feb 2024 13:07:48 -0500 Subject: [PATCH] Write the package.json and package-lock.json files with pretty json formatting --- cmd/soroban-cli/src/commands/contract/init.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/init.rs b/cmd/soroban-cli/src/commands/contract/init.rs index 7309718a37..b3a940de5e 100644 --- a/cmd/soroban-cli/src/commands/contract/init.rs +++ b/cmd/soroban-cli/src/commands/contract/init.rs @@ -16,7 +16,7 @@ use clap::{ use gix::{clone, create, open, progress, remote}; use rust_embed::RustEmbed; use serde::Deserialize; -use serde_json::{from_str, json, Error as JsonError, Value as JsonValue}; +use serde_json::{from_str, json, to_string_pretty, Error as JsonError, Value as JsonValue}; use toml_edit::{Document, Formatted, InlineTable, Item, TomlError, Value as TomlValue}; use ureq::{get, Error as UreqError}; @@ -438,7 +438,9 @@ fn edit_package_name( doc["name"] = json!(package_name.to_string_lossy()); - write(&file_path, doc.to_string())?; + let formatted_json = to_string_pretty(&doc)?; + + write(&file_path, formatted_json)?; Ok(()) }