mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-24 06:34:09 +00:00
json5 work
This commit is contained in:
parent
cd63b5c9c0
commit
fdd1d145cf
22 changed files with 1977 additions and 90 deletions
|
|
@ -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")?;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue