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

🐛 updating gitignore by adding a new line #186 #187

Merged
merged 2 commits into from
Aug 16, 2024
Merged
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
12 changes: 11 additions & 1 deletion crates/client/src/test_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,20 @@ impl TestGenerator {
return;
}
}
// Check if the file ends with a newline
let mut file = File::open(&gitignore_path)?;
let mut buf = [0; 1];
file.seek(io::SeekFrom::End(-1))?;
file.read_exact(&mut buf)?;

let file = OpenOptions::new().append(true).open(gitignore_path);

if let Ok(mut file) = file {
writeln!(file, "{}", ignored_path)?;
if buf[0] == b'\n' {
writeln!(file, "{}", ignored_path)?;
} else {
writeln!(file, "\n{}", ignored_path)?;
}
println!("{FINISH} [{GIT_IGNORE}] update with [{ignored_path}]");
}
} else {
Expand Down
Loading