Hacker News new | ask | show | jobs
by bebrws 660 days ago
In this blog post, I show how I created a preprocessor that takes any line starting with “// log -” and creates a temporary intermediary file where those lines are replaced with console.log statements to print any expressions following “// log -”. This approach is useful in several ways. It’s easier than using console.log directly, and when run without using the preprocessor, these log lines are simply ignored. The entire setup is straightforward, utilizing a Node.js environment variable/option to run the preprocessor.