From ddac43f4ba0dc804626d84026b757503da70eacb Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 9 Jun 2009 10:06:04 +0200 Subject: [PATCH] Allow for absolute paths to specify root module --- src/node.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index bca29bdcd0..6c72565323 100644 --- a/src/node.js +++ b/src/node.js @@ -52,6 +52,13 @@ node.path = new function () { var parts = path.split("/"); return parts.slice(0, parts.length-1).join("/"); }; + + this.filename = function (path) { + if (path.charAt(0) !== "/") + path = "./" + path; + var parts = path.split("/"); + return parts[parts.length-1]; + }; }; // Module @@ -165,7 +172,11 @@ node.Module.prototype.exit = function (callback) { (function () { // Load the root module. I.E. the command line argument. - root_module = new node.Module({ path: ARGV[1], target: this }); + root_module = new node.Module({ + path: node.path.filename(ARGV[1]), + base_directory: node.path.dirname(ARGV[1]), + target: this + }); root_module.load(); node.exit = function (code) {