From 6acac912dd4da0479a0630a8d1b2878ca83b22de Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 3 Aug 2009 18:39:37 +0200 Subject: [PATCH] Initial support for shebang. There are some issues with loading modules from shebang-executed scripts that will still need to be addressed, but this works for simple single script situations. --- src/node.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node.js b/src/node.js index 1716e4b0bc..271458e928 100644 --- a/src/node.js +++ b/src/node.js @@ -81,6 +81,9 @@ node.Module.prototype.load = function (callback) { 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; "+