diff options
author | Yusuke Tanaka <yusuktan@maguro.dev> | 2021-06-04 03:49:02 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 20:49:02 +0200 |
commit | 41e9a21307f87e0a79766fc879a3a0b06dc57eb2 (patch) | |
tree | 653684727bb481de5bfdb8bb858aa96d0271e4a4 /cli | |
parent | 03184aeabb3e5f70aa9e66fd279b0285b810a830 (diff) |
fix(cli): output json with trailing newline character (#10830)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/main.rs | 6 | ||||
-rw-r--r-- | cli/tests/055_info_file_json.out | 2 | ||||
-rw-r--r-- | cli/tests/076_info_json_deps_order.out | 2 | ||||
-rw-r--r-- | cli/tests/info_json.out | 2 | ||||
-rw-r--r-- | cli/tests/info_json_location.out | 2 |
5 files changed, 8 insertions, 6 deletions
diff --git a/cli/main.rs b/cli/main.rs index db99d4e4e..23b51219f 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -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( diff --git a/cli/tests/055_info_file_json.out b/cli/tests/055_info_file_json.out index 602c48b32..f2f664572 100644 --- a/cli/tests/055_info_file_json.out +++ b/cli/tests/055_info_file_json.out @@ -53,4 +53,4 @@ } ], "size": 757 -}
\ No newline at end of file +} diff --git a/cli/tests/076_info_json_deps_order.out b/cli/tests/076_info_json_deps_order.out index 2d87a1054..2afd97b49 100644 --- a/cli/tests/076_info_json_deps_order.out +++ b/cli/tests/076_info_json_deps_order.out @@ -82,4 +82,4 @@ } ], "size": 475 -}
\ No newline at end of file +} diff --git a/cli/tests/info_json.out b/cli/tests/info_json.out index a0d316307..4ba5a95f4 100644 --- a/cli/tests/info_json.out +++ b/cli/tests/info_json.out @@ -4,4 +4,4 @@ "typescriptCache": "[WILDCARD]gen", "registryCache": "[WILDCARD]registries", "originStorage": "[WILDCARD]location_data" -}
\ No newline at end of file +} diff --git a/cli/tests/info_json_location.out b/cli/tests/info_json_location.out index dd9377d3b..6c4cddefb 100644 --- a/cli/tests/info_json_location.out +++ b/cli/tests/info_json_location.out @@ -5,4 +5,4 @@ "registryCache": "[WILDCARD]registries", "originStorage": "[WILDCARD]location_data[WILDCARD]", "localStorage": "[WILDCARD]location_data[WILDCARD]local_storage" -}
\ No newline at end of file +} |