Skip to content

Commit

Permalink
feat(init): add entry to gitignore file
Browse files Browse the repository at this point in the history
  • Loading branch information
beeb committed Aug 21, 2024
1 parent f5fcad8 commit 49a645a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/commands/init.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::fs;

use super::Result;
use crate::{
config::{add_to_config, get_config_path, read_soldeer_config, remove_forge_lib},
install::{ensure_dependencies_dir, install_dependency, Progress},
lock::add_to_lockfile,
registry::get_latest_forge_std,
remappings::add_to_remappings,
utils::get_current_working_dir,
};
use clap::Parser;
use cliclack::{
Expand Down Expand Up @@ -49,6 +52,16 @@ pub(crate) async fn init_command(cmd: Init) -> Result<()> {
success("Dependency added to lockfile")?;
add_to_remappings(dependency, &config, &config_path).await?;
success("Dependency added to remappings")?;
// TODO: add `dependencies` to the .gitignore file if it exists

let gitignore_path = get_current_working_dir().join(".gitignore");
if gitignore_path.exists() {
let mut gitignore = fs::read_to_string(&gitignore_path)?;
if !gitignore.contains("dependencies") {
gitignore.push_str("\n\n# Soldeer\n/dependencies\n");
fs::write(&gitignore_path, gitignore)?;
}
}
success("Added `dependencies` to .gitignore")?;

Ok(())
}

0 comments on commit 49a645a

Please sign in to comment.