OSD600 - Reviewing SSG Code
Tags: opensource, cli, review
Published: 2021-09-17 04:42:43

The partner I worked with during this review lab is Minh Hang Nguyen. As we both used Node.js to create the tool, it is easier for us to detect any mistake contained in the code.

#### 1. Minh Hang's Git Repo 
Firstly, I was surprised when reviewing her source code since the *logic* is very *clear* and *careful*. She even checked for empty path input which I did not think about until reading her code. Additionally, whenever the tool finished, the `-h` or `--help` feature is displayed allowing users to understand more about the tool's features. I think I should apply the same thing for my tool later on. 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/874enba21vgv6v54rj7i.png)

Secondly, the source code is *neat* and *easy to understand*, all generated HTML files are stored in `./dist` folder if there is no output directory specified. However, the data contained in generated HTML files is displayed [a little messy](https://github.com/minhhang107/mh-ssg/issues/1) so it should be improve for a better look.

Thirdly, all required features are applied and work properly, but there is a mistake in optional features:

* [Parsing title](https://github.com/minhhang107/mh-ssg/issues/2): If there is a title, it will be the first line followed by two blank lines. However, the program will set the whole first paragraph as the title if there are no two blank lines.

Lastly, I [suggested](https://github.com/minhhang107/mh-ssg/issues/3) her to use `chalk` package for log message/error so it will make the tool more attractive.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/flqo7jeuily3fgbn31vb.png)
 
View Minh Hang's repo at https://github.com/minhhang107/mh-ssg

#### 2. My Git Repo

At first, Minh Hang found out the `-o` or `--output` option specified in the help section, however, it [has not been applied yet](https://github.com/hlavu/my-ssg/issues/4). I solved this problem by commenting this option out cause I intend to implement that feature in the next version of the tool.

Next, she suggests that I should **modify** my **README** file in two points:
* Add installation details to help people who are not familiar with Node.js approach to the tool more convenient.
* Use parallel structures in Features section to make the instruction more professional.

Then, she realized I [did not check for file extension](https://github.com/hlavu/my-ssg/issues/7) if user specifies a folder as the input. As a result, all types of file in the folder will be converted into `.html`. My **solution** is, using `filter()` function to get all `.txt` files then convert them.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tyfxg0ve4xoawq9mmo8s.png)
 

The last mistake she found out is that my tool [can not read an input contained spaces](https://github.com/hlavu/my-ssg/issues/6). I fixed this by changing type of the input option into `array` (it is `string` before) then passing the input to check status after I use the `join()` function to combine the path together.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w474euk3gsy226bpup31.png)

My repo: https://github.com/hlavu/my-ssg

All in all, code review is the best way to exchange information and learn new techniques. I gained a lot of new experiences after completing this lab. I have learned many new things from Minh Hang (Thank you so much ^^).

Happy coding!