1st collaboration for open source
Tags: opensource, osd600
Published: 2021-09-16 19:54:02

Vivian and I first met last semester. I happened to know that she is also using NodeJs for this project so I reached out to her for collaboration. My aim is to become stronger in Node so I believe finding a partner with the same interest would be beneficial.

At first, the idea of reviewing someone else's code is daunting to me. Everyone uses different logic and different tools to implement that logic. Understanding their logic would probably take a little time but it's also an interesting experience. Reviewing Vivian's code, I can see that she has very clean formatting and the logic is very easy to understand. What surprised me was how she improved the appearance of her tool. She used `chalk` package to colorized different types of message in her tool. I believe it's very creative and also effective. It helps users easily see the results of the run. 

During the testing and reviewing for her code, I have encountered both minor and major issues. Minor issues are related to documentation: there was a [mismatch between actual functionalities and the options in Help section](https://github.com/hlavu/my-ssg/issues/4) and Readme file was [missing installation guide](https://github.com/hlavu/my-ssg/issues/5). Both  were quickly resolved after the issues were filed.

The major issues are related to the main feature. At first, the tool was [unable to process input that has spaces](https://github.com/hlavu/my-ssg/issues/6). She was using [Yargs](https://github.com/yargs/yargs) to parse the arguments, however, arguments are separated with space by default so if the input includes spaces, Yargs will parse only the first word into the option. I suggested that she looked into `argv.input` to find the solution. Another issue was that when a directory is specified as input, the tool would [process all files inside regardless of the file type](https://github.com/hlavu/my-ssg/issues/7). When I looked at her code again, I could see that she was missing a check for file extension.

Vivian found [a bug with my stylesheet feature](https://github.com/minhhang107/mh-ssg/issues/2). The title is defined as the first line of the file followed by two new lines. Some files have a title and some don't. My tool was assuming that every file has a title, hence failed to do the check. Therefore, if the input file doesn't have a title, the tool will generate the wrong title for it. I was able to fix this by adding a quick check before creating the HTML file.

The other two issues were related to formatting. Vivian gave me two suggestions: to [re-format the generated HTML](https://github.com/minhhang107/mh-ssg/issues/1) and to [improve the appearance of the tool](https://github.com/minhhang107/mh-ssg/issues/3) by using `chalk` to colorize the tool and emphasize the features. 

> *Vivian's demo of my tool with `chalk`*
![suggestion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c52oirqiddacuh05hj6g.png)

The HTML format was messy because I was creating the HTML template manually. I looked up some packages and decided to use [create-html](https://www.npmjs.com/package/create-html) to generate better format for the file. As for the second suggestion, I'm planning to implement `chalk` in the next release.

After testing and reviewing other's code, I realize that this is actually a fun process. I'm not just learning someone else's logic and new tools but this is also a chance for me to review my code. I can see what I'm missing or what I can improve in my code. Moreover, each person might come up with new test cases, making the testing process even more comprehensive, preventing any possible bugs.