DEV Community

Ririio
Ririio

Posted on

Git Refactoring Code

I've always had problems in terms of fixing multiple things with my code. Whenever I make multiple changes, I always thought that having my commit message explaining everything would be the best choice or I can simply commit and then push every single time.

Refactoring and rebase makes my life much easier for I can simply commit onto multiple bug fixes and addition and combining them all into a singular push.

Adding new functionalities

When writing my code, I noticed that when working with my replaceDirectory and changeLanguage function, that they have the same format with only a slight difference

Image description

With this thought, I realized that instead of simply repeating the code over and over again when working with the .env file, I can simply create a function that will do this for me thus readFileEnv was created. It takes 3 arguments and uses these values in terms of the message display, value to change, and which key to use

Finding bugs

I noticed that my output always creates a folder when the command line is used. This is a problem, because the user can simply change the output and a substantial amount of empty folder will be created. I fixed this by removing the createFolder when the command line is used, and simply overwrite the value of the .env file

Top comments (0)