Skip to content

Commit

Permalink
fixed release build issue and refactored stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaSTL committed Nov 5, 2023
1 parent 1e7d7b5 commit 0f8fb26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Command/CommandInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ bool createProject(Interface *inter){
createHelloWorldC(inter->pro);
}
#ifndef DEBUG
Generators::GitIgnore::create(pro);
int gitinit = std::system(("cd "+pro->project_path.string()+";git init").c_str());
Generators::GitIgnore::create(inter->pro);
int gitinit = std::system(("cd "+inter->pro->project_path.string()+";git init").c_str());
if(gitinit != 0){
std::cout << termcolor::red << "We had problems initializing your project with git" << termcolor::reset << ENDL;
}
Expand Down
34 changes: 16 additions & 18 deletions src/Generators/GitIgnoreGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@


namespace Generators::GitIgnore{

bool write_gitignore(std::string gitignore, std::filesystem::path gitignore_path) {
try{
std::ofstream file;
file.open(gitignore_path);
file << gitignore;
file.close();
}catch(std::exception &e){
std::cout << "Failed to create gitignore" << std::endl;
return false;
}
return true;
}

using namespace Utils::CLI;
bool create(std::shared_ptr<Command::Project> pro){
std::filesystem::path gitignore_path = pro->project_path / ".gitignore";
Expand Down Expand Up @@ -41,29 +55,13 @@ compile_commands.json
Prompt<bool> *prompt = new Prompt<bool>("Do you want to overwrite it?");
prompt->Color(Ansi::RED)->ExitOnFailure()->Run();
if(prompt->Get()){
try{
std::ofstream file;
file.open(gitignore_path);
file << gitignore;
file.close();
}catch(std::exception &e){
std::cout << "Failed to create gitignore" << std::endl;
return false;
}
write_gitignore(gitignore, gitignore_path);
return true;
}else{
return false;
}
}else{
try{
std::ofstream file;
file.open(gitignore_path);
file << gitignore;
file.close();
}catch(std::exception &e){
std::cout << "Failed to create gitignore" << std::endl;
return false;
}
write_gitignore(gitignore, gitignore_path);
}

return true;
Expand Down

0 comments on commit 0f8fb26

Please sign in to comment.