Add newline to end of plan json output (#283)

* Add newline to end of `plan` json output

This causes some shells (like sh) to continue their prompt right after
the closing brace, which is kinda meh.

* Add newline to end of `receipt.json`

`cat /nix/receipt.json` has the same issue as the previous commit, in
that it will bleed into the prompt for some shells that don't insert an
implicit newline.

* Add newline to end of fixture json documents
This commit is contained in:
Cole Helbling 2023-02-28 08:38:42 -08:00 committed by GitHub
parent d49e12cd7d
commit 9c8284cd06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 5 deletions

View file

@ -44,7 +44,7 @@ impl CommandExecute for Plan {
};
let json = serde_json::to_string_pretty(&install_plan)?;
tokio::fs::write(output, json)
tokio::fs::write(output, format!("{json}\n"))
.await
.wrap_err("Writing plan")?;

View file

@ -331,7 +331,7 @@ async fn write_receipt(plan: InstallPlan) -> Result<(), NixInstallerError> {
let install_receipt_path = PathBuf::from(RECEIPT_LOCATION);
let self_json =
serde_json::to_string_pretty(&plan).map_err(NixInstallerError::SerializingReceipt)?;
tokio::fs::write(&install_receipt_path, self_json)
tokio::fs::write(&install_receipt_path, format!("{self_json}\n"))
.await
.map_err(|e| NixInstallerError::RecordingReceipt(install_receipt_path, e))?;
Result::<(), NixInstallerError>::Ok(())

View file

@ -915,4 +915,4 @@
"start_daemon": true
}
}
}
}

View file

@ -937,4 +937,4 @@
"start_daemon": true
}
}
}
}

View file

@ -969,4 +969,4 @@
"volume_label": "Nix Store",
"root_disk": "disk3"
}
}
}