I\'m writing a web app in Node. If I\'ve got some JS file db.js with a function init in it how could I call that function from the command line?
db.js
init
Sometimes you want to run a function via CLI, sometimes you want to require it from another module. Here's how to do both.
require
// file to run const runMe = () => {} if (require.main === module) { runMe() } module.exports = runMe