3

I have a node.js file:

#!/usr/bin/env node

module.exports = 'foo';

I'm trying to add, at the bottom:

if(is run as shell script){
    console.log(module.exports);
}

Is there a proper way to do this? I can hack something together using things like process.argv and __filename, but is that the best way?

0 Answers0