I have a file doSomething.js that contains some code that needs to be run both from the command line (eg: node doSomething.js) and also from a nodejs-based queue worker
queueWorker.js
var worker = client.worker(['example']);
worker.register({
doSomething: function (params, callback) {
// run the code contained in doSomething.js
}
});
worker.start();
doSomething.js
console.log('Hello world')
Question: Is there a way to let the main code remain in doSomething.js and just include a reference to doSomething.js in queueWorker.js? I dont want to have 2 copies of the same code in 2 different files.