Last active
August 29, 2015 14:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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