Skip to content

Instantly share code, notes, and snippets.

@mimiflynn
Last active August 29, 2015 14:05
Show Gist options
  • Save mimiflynn/caac370d021dbc222b3f to your computer and use it in GitHub Desktop.
Save mimiflynn/caac370d021dbc222b3f to your computer and use it in GitHub Desktop.
Fun little test script to play around with using nodejs as a command line utility
#!/usr/bin/env node
console.log('this is a growl test script to play with node and growl');
if (process.argv[3]) {
// how to grab arguments from the command line
console.log('The arguments are: ', process.argv);
} else {
console.log('No arguments. Try running growlfun with some arguments');
}
// how to require modules
var growl = require('/usr/local/lib/node_modules/growl');
// keep that process going
process.stdin.resume();
// Send a growl notification and a console log when the process is killed
process.on('SIGINT', function () {
console.log("I'm dying!");
growl('You just killed the growlfun process. BOOOO!!!!');
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment