Skip to content

Commit

Permalink
fix(cli): output json with trailing newline character (denoland#10830)
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna committed Jun 3, 2021
1 parent 03184ae commit 41e9a21
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ pub fn write_json_to_stdout<T>(value: &T) -> Result<(), AnyError>
where
T: ?Sized + serde::ser::Serialize,
{
let writer = std::io::BufWriter::new(std::io::stdout());
serde_json::to_writer_pretty(writer, value).map_err(AnyError::from)
let mut writer = std::io::BufWriter::new(std::io::stdout());
serde_json::to_writer_pretty(&mut writer, value)?;
writeln!(&mut writer)?;
Ok(())
}

fn print_cache_info(
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/055_info_file_json.out
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
}
],
"size": 757
}
}
2 changes: 1 addition & 1 deletion cli/tests/076_info_json_deps_order.out
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@
}
],
"size": 475
}
}
2 changes: 1 addition & 1 deletion cli/tests/info_json.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"typescriptCache": "[WILDCARD]gen",
"registryCache": "[WILDCARD]registries",
"originStorage": "[WILDCARD]location_data"
}
}
2 changes: 1 addition & 1 deletion cli/tests/info_json_location.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"registryCache": "[WILDCARD]registries",
"originStorage": "[WILDCARD]location_data[WILDCARD]",
"localStorage": "[WILDCARD]location_data[WILDCARD]local_storage"
}
}

0 comments on commit 41e9a21

Please sign in to comment.