DEV Community

jjung99
jjung99

Posted on • Edited on

Adding new feature using remotes

I added a new feature from the new branch in the cloned repository in this lab. And I updated it to the remote repo using the git merge and push function.

The newly added functions are as follows.

  • Using the new command option -c and -config, receive the JSON file as an argument.

  • Import data corresponding to the SSG option from the JSON file.

  • Applying the imported data to the proper value or function (e.g., input, stylesheet etc.)


The following is an example of the code I updated. There were many if statements in the code, so the structure was more complicated than I contributed last time.

First of all, I added json file and put data in it.

 fs.readFile(TextArr.length > 1 ? './Texts/'.concat(filename, "/", TextArr[filenum][0], ".", TextArr[filenum][1]) : './Texts/'.concat(TextArr[filenum][0], ".", Text
Enter fullscreen mode Exit fullscreen mode

The JSON file was created in the Test directory because the file was read from the directory "Texts".
alt text

Secondly, I added if statements when it accepts -config command option and few other code lines accordingly.

            if(options.config){
                const json = args.slice(3).join(' ').toString();
                jsonData = require(`../${json}`);
                filename = jsonData.input;
                url = jsonData.stylesheet;
            }
Enter fullscreen mode Exit fullscreen mode

Finally, I pushed it into the working branch of my fork repository. And I reviewed my pull request as well.

I was confused about the concept of git remote and the clear difference between git merge and fetch. However, working on git and trying things after watching the git lecture, I know git fetch is for reading and merge is for updating the code. I can't say I am comfortable using git yet, but I definitely understood that it would be so handy once I practice it a lot.

Top comments (1)

Collapse
 
juuuuuuun profile image
jsong89

Nice post XD