22 January 2022
26 March 2016
Make your hubot coffee scripts into reusable standalone programs
In part 1 of this 2 part series on making your module.exports reusable as standalone programs in JavaScript/CoffeeScript, I explained that this pattern allows for flexible reuse of a function like main
:
var main = function(args) {
console.log(args)
}
module.exports = main
if (module.parent === null) {
main(process.argv)
}
In this article, I’ll show how to make a hubot script that wraps the dig
command into a reusable standalone program. Assuming you’re using Linux, OSX, or another BSD and you have dig installed, let’s get started.
19 March 2016
Make your Node.js module.exports more reusable as a standalone program
Likely we’ve all written something that is structurally like this when writing helper functions in JavaScript & CoffeeScript (I’ll be using JavaScript syntax in this article, but the principle is the same in CoffeeScript):
module.exports = function(args) {
//something something here
}
And you’re all set to reuse your something something here anonymous functionalty elsewhere in your application’s codebase.