json5 work

This commit is contained in:
Joe 2026-01-22 22:19:00 -06:00
parent cd63b5c9c0
commit fdd1d145cf
22 changed files with 1977 additions and 90 deletions

View file

@ -25,8 +25,11 @@ impl FmtProjectCommand {
let project = Project::load_fuzzy(&vfs, &base_path)?
.context("A project file is required to run 'rojo fmt-project'")?;
let serialized = serde_json::to_string_pretty(&project)
.context("could not re-encode project file as JSON")?;
let serialized = String::from_utf8(
crate::json::to_vec_pretty_sorted(&project)
.context("could not re-encode project file as JSON5")?,
)
.context("JSON5 output was not valid UTF-8")?;
fs_err::write(&project.file_location, serialized)
.context("could not write back to project file")?;

View file

@ -239,12 +239,13 @@ fn write_sourcemap(
if let Some(output_path) = output {
let mut file = BufWriter::new(File::create(output_path)?);
serde_json::to_writer(&mut file, &root_node)?;
let json_output = json5::to_string(&root_node)?;
file.write_all(json_output.as_bytes())?;
file.flush()?;
println!("Created sourcemap at {}", output_path.display());
} else {
let output = serde_json::to_string(&root_node)?;
let output = json5::to_string(&root_node)?;
println!("{}", output);
}