I don't have the setup to try this right now, but would something like
this work with current node?
#!/usr/bin/env node
// Code goes here
It would be nice to write everything in node itself (for example a
simple test runner for my library or a script to concatenate files).
Urban
Ah, right. I forgot.
Urban
Look at the bottom of the file src/node.js - there it loads the
root_module, the module which was given on the command line. The file
can easily be scanned for a shebang (use a regexp) and removed before
compiling it (see node.compile() in node.Module.prototype.load()).
self.target.__require = function (path) { return
self.newChild(path, {}); };
self.target.__include = function (path) { self.newChild(path,
self.target); };
+ // remove shebang
+ content = content.replace(/^\#\!.*/, '');
+
// create wrapper function
var wrapper = "function (__filename) { "+
" var onLoad; "+
Module loading isn't working yet from shebang scripts (unless they're
specified with a full path :P), but this handles the most trivial case
and encourages myself to finish it.
2009/6/26 ryan dahl <coldre...@gmail.com>: