Is there a clever way to create a module that can both be run with index.js arg1 arg2 as well as exporting itself to be used by others, ie. module.exports?
Say I have a script that kickstart a proxy server, while I can do proxy.js host port, I can't think of an easy way to export it as well. Should I look at process.argv to decide whether to exports or run itself? Or is there a better pattern?
PS: I was trying to write test cases for it but realize without module.exports, it's kinda hard to provide proper test coverage. Just curious how one would tackle this.