Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Created May 19, 2011 14:41
Show Gist options
  • Save billywhizz/980894 to your computer and use it in GitHub Desktop.
Save billywhizz/980894 to your computer and use it in GitHub Desktop.
module configuration example
// this is just a standard node.js module
exports.foo = function() {
return ("hello from " + process.ARGV[2]);
}
#!/usr/local/bin/node
// put all your standard requires in here and they will be available globally
global.mylib = require("./mylib");
// remove this script from the arguments list
process.ARGV.slice(1,1);
module.load(process.ARGV[2], null, true);
// run with ./mynode ./test.js
console.log(mylib.foo());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment