Introduction
This is the second blog in a series of three, where I am sharing my experience contributing to the Node.js core repository. You can read the previous blog here: , which prints the error message when the test coverage threshold isn't met.
in tests_stream.js.
diagnostic(nesting, loc, message, level = 'info') {
this[kEmitMessage]('test:diagnostic', {
__proto__: null,
nesting,
message,
level,
...loc,
});
}
I added a level parameter here, defaulting it to 'info'. This was the first step to make the error color configurable.
Adding Logic for Severity-Based Colors
Next, I located the handler for test:diagnostic in and updated it to map severity levels to appropriate colors. Here’s the updated code:
const reporterColorMap = {
'__proto__': null,
get 'test:fail'() {
return colors.red;
},
get 'test:pass'() {
return colors.green;
},
get 'test:diagnostic'() {
return colors.blue;
},
get 'info'() {
return colors.blue;
},
get 'warn'() {
return colors.yellow;
},
get 'error'() {
return colors.red;
},
};
With these changes, the level parameter now dynamically controls the color of the diagnostic message, making it easier for developers to identify severity levels at a glance.
Building Node.js Locally
Now that the changes were made, it was time to test my work. To do this, I needed to build Node.js locally. I referred to the
Testing the Build
After preparing the prerequisites using Boxstarter, I started building Node.js locally. However, the build process ran for over 1 hour and 30 minutes without completing. This seemed unusual, so I asked the maintainer about it in the issue thread. They mentioned that the build process typically takes about 25 minutes.
Opening a Pull Request
After confirming that my changes worked, I committed them and opened a
Conclusion
That’s it for this blog. In the next blog, I will share how I updated the documentation and added test cases to complete the pull request.
SOCIAL SHARE CARD GENERATOR