Add .gitignore

This commit is contained in:
mo8it 2024-03-31 02:04:41 +01:00
parent 1e1f031713
commit b711dd692a

View File

@ -32,6 +32,15 @@ publish = false
.write_all(&cargo_toml) .write_all(&cargo_toml)
} }
fn create_gitignore() -> io::Result<()> {
let gitignore = b"/target";
OpenOptions::new()
.create_new(true)
.write(true)
.open(".gitignore")?
.write_all(gitignore)
}
fn create_vscode_dir() -> Result<()> { fn create_vscode_dir() -> Result<()> {
create_dir(".vscode").context("Failed to create the directory `.vscode`")?; create_dir(".vscode").context("Failed to create the directory `.vscode`")?;
let vs_code_extensions_json = br#"{"recommendations":["rust-lang.rust-analyzer"]}"#; let vs_code_extensions_json = br#"{"recommendations":["rust-lang.rust-analyzer"]}"#;
@ -77,6 +86,8 @@ Then run `rustlings` again"
create_cargo_toml(exercises).context("Failed to create the file `rustlings/Cargo.toml`")?; create_cargo_toml(exercises).context("Failed to create the file `rustlings/Cargo.toml`")?;
create_gitignore().context("Failed to create the file `rustlings/.gitignore`")?;
create_vscode_dir().context("Failed to create the file `rustlings/.vscode/extensions.json`")?; create_vscode_dir().context("Failed to create the file `rustlings/.vscode/extensions.json`")?;
Ok(()) Ok(())