Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EOL at EOF for JSON files #238

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion butane_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ impl CliState {
pub fn save(&self, base_dir: &Path) -> Result<()> {
let path = base_dir.join("clistate.json");
let mut file = File::create(path)?;
file.write_all(serde_json::to_string_pretty(self)?.as_bytes())?;
let mut contents = serde_json::to_string_pretty(self)?;
contents.push('\n');
file.write_all(contents.as_bytes())?;
Ok(())
}
}
Expand Down
5 changes: 3 additions & 2 deletions butane_core/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ impl ConnectionSpec {
pub fn save(&self, path: &Path) -> Result<()> {
let path = conn_complete_if_dir(path);
let mut f = fs::File::create(path)?;
f.write_all(serde_json::to_string_pretty(self)?.as_bytes())
.map_err(|e| e.into())
let mut contents = serde_json::to_string_pretty(self)?;
contents.push('\n');
f.write_all(contents.as_bytes()).map_err(|e| e.into())
}
/// Load a previously saved connection spec
pub fn load(path: impl AsRef<Path>) -> Result<Self> {
Expand Down
9 changes: 6 additions & 3 deletions butane_core/src/migrations/fsmigrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ impl FsMigration {
}

fn write_info(&self, info: &MigrationInfo) -> Result<()> {
self.write_contents("info.json", serde_json::to_string_pretty(info)?.as_bytes())
let mut contents = serde_json::to_string_pretty(info)?;
contents.push('\n');
self.write_contents("info.json", contents.as_bytes())
}

fn write_sql(&self, name: &str, sql: &str) -> Result<()> {
Expand Down Expand Up @@ -380,8 +382,9 @@ impl FsMigrations {
}
let path = self.root.join("state.json");
let mut f = self.fs.write(&path)?;
f.write_all(serde_json::to_string_pretty(state)?.as_bytes())
.map_err(|e| e.into())
let mut contents = serde_json::to_string_pretty(state)?;
contents.push('\n');
f.write_all(contents.as_bytes()).map_err(|e| e.into())
}
/// Detach the latest migration from the list of migrations,
/// leaving the migration on the filesystem.
Expand Down
2 changes: 1 addition & 1 deletion examples/getting_started/.butane/clistate.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"embedded": true
"embedded": true
}