DEV Community

Minh Hang Nguyen
Minh Hang Nguyen

Posted on

1st collaboration for open source

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 and Readme file was missing installation guide. 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. She was using 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. 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. 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 and to improve the appearance of the tool by using chalk to colorize the tool and emphasize the features.

Vivian's demo of my tool with chalk

The HTML format was messy because I was creating the HTML template manually. I looked up some packages and decided to use 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.

Top comments (2)

lencx profile image

In addition to chalk, there are some libraries to try, I collected a list: Node.js Terminal Libraries

minhhang107 profile image
Minh Hang Nguyen

Thank you! I'll take a look and try them out when possible