felixge (owner)

Revisions

  • fb50c3 felixge Mon Nov 02 12:23:29 -0800 2009
  • 97f0b9 felixge Mon Nov 02 12:21:21 -0800 2009
gist: 224426 Download_button fork
public
Public Clone URL: git://gist.github.com/224426.git
Embed All Files: show embed
0001-The-return-of-relative-module-loading.patch #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From d0f12db30b0845c0a0d8e3311d96bd094038dc6a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Felix=20Geisend=C3=B6rfer?= <felix@debuggable.com>
Date: Mon, 2 Nov 2009 21:21:02 +0100
Subject: [PATCH] The return of relative module loading
 
---
 src/node.js | 2 +-
 test/mjsunit/test-module-loading.js | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
 
diff --git a/src/node.js b/src/node.js
index 2833a03..752a2a3 100644
--- a/src/node.js
+++ b/src/node.js
@@ -342,7 +342,7 @@ function loadModule (request, parent) {
   debug("loadModule REQUEST " + JSON.stringify(request) + " parent: " + JSON.stringify(parent));
 
   var id, paths;
- if (request.charAt(0) == "." && request.charAt(1) == "/") {
+ if (request.charAt(0) == "." && (request.charAt(1) == "/" || request.charAt(1) == ".")) {
     // Relative request
     id = path.join(path.dirname(parent.id), request);
     paths = [path.dirname(parent.filename)];
diff --git a/test/mjsunit/test-module-loading.js b/test/mjsunit/test-module-loading.js
index 769c1b4..7670837 100644
--- a/test/mjsunit/test-module-loading.js
+++ b/test/mjsunit/test-module-loading.js
@@ -5,7 +5,10 @@ debug("load test-module-loading.js");
 var a = require("./fixtures/a");
 var d = require("./fixtures/b/d");
 var d2 = require("./fixtures/b/d");
+// Absolute
 var d3 = require(require('path').dirname(__filename)+"/fixtures/b/d");
+// Relative
+var d4 = require("../mjsunit/fixtures/b/d");
 
 assertFalse(false, "testing the test program.");
 
@@ -27,6 +30,9 @@ assertEquals("D", d2.D());
 assertInstanceof(d3.D, Function);
 assertEquals("D", d3.D());
 
+assertInstanceof(d4.D, Function);
+assertEquals("D", d4.D());
+
 process.addListener("exit", function () {
   assertInstanceof(a.A, Function);
   assertEquals("A done", a.A());
--
1.6.3.3