Skip to content

Commit

Permalink
make.rs: rename create_makefile to new, new to new_internal
Browse files Browse the repository at this point in the history
  • Loading branch information
kyu08 committed Nov 24, 2024
1 parent 9f46fae commit 8917117
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/model/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ impl Make {
format!("make {}", command.name)
}

pub fn create_makefile(current_dir: PathBuf) -> Result<Make> {
pub fn new(current_dir: PathBuf) -> Result<Make> {
let Some(makefile_name) = Make::specify_makefile_name(current_dir, ".".to_string()) else {
return Err(anyhow!("makefile not found.\n"));
};
Make::new(Path::new(&makefile_name).to_path_buf())
Make::new_internal(Path::new(&makefile_name).to_path_buf())
}

pub fn to_commands(&self) -> Vec<command::Command> {
Expand All @@ -39,13 +39,13 @@ impl Make {

// I gave up writing tests using temp_dir because it was too difficult (it was necessary to change the implementation to some extent).
// It is not difficult to ensure that it works with manual tests, so I will not do it for now.
fn new(path: PathBuf) -> Result<Make> {
fn new_internal(path: PathBuf) -> Result<Make> {
// If the file path does not exist, the make command cannot be executed in the first place,
// so it is not handled here.
let file_content = file_util::path_to_content(path.clone())?;
let include_files = content_to_include_file_paths(file_content.clone())
.iter()
.map(|included_file_path| Make::new(included_file_path.clone()))
.map(|included_file_path| Make::new_internal(included_file_path.clone()))
.filter_map(Result::ok)
.collect();

Expand Down
2 changes: 1 addition & 1 deletion src/usecase/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl SelectCommandState<'_> {
Ok(d) => d,
Err(e) => bail!("Failed to get current directory: {}", e),
};
let makefile = match Make::create_makefile(current_dir.clone()) {
let makefile = match Make::new(current_dir.clone()) {
Err(e) => return Err(e),
Ok(f) => f,
};
Expand Down

0 comments on commit 8917117

Please sign in to comment.