Skip to content

Commit 04e53ca

Browse files
committed
Rename node.libraryPaths to require.paths
to be more inline with CommonJS.
1 parent 4bcb01c commit 04e53ca

File tree

8 files changed

+10
-9
lines changed

8 files changed

+10
-9
lines changed

benchmark/http_simple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
libDir = node.path.join(node.path.dirname(__filename), "../lib");
2-
node.libraryPaths.unshift(libDir);
2+
require.paths.unshift(libDir);
33

44
node.mixin(require("/utils.js"));
55
http = require("/http.js");

benchmark/process_loop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
libDir = node.path.join(node.path.dirname(__filename), "../lib");
2-
node.libraryPaths.unshift(libDir);
2+
require.paths.unshift(libDir);
33
node.mixin(require("/utils.js"));
44
function next (i) {
55
if (i <= 0) return;

benchmark/run.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
libDir = node.path.join(node.path.dirname(__filename), "../lib");
2-
node.libraryPaths.unshift(libDir);
2+
require.paths.unshift(libDir);
33
node.mixin(require("/utils.js"));
44
var benchmarks = [ "static_http_server.js"
55
, "timers.js"

benchmark/static_http_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
libDir = node.path.join(node.path.dirname(__filename), "../lib");
2-
node.libraryPaths.unshift(libDir);
2+
require.paths.unshift(libDir);
33
http = require("/http.js");
44
var concurrency = 30;
55
var port = 8000;

doc/api.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ more information.
7373
+require(path)+ ::
7474
See the modules section.
7575

76-
+node.libraryPaths+ ::
76+
+require.paths+ ::
7777
The search path for absolute path arguments to +require()+.
7878

7979
+node.mixin([deep], target, object1, [objectN])+ ::
@@ -369,7 +369,7 @@ puts("The area of a cirlce of radius 4 is " + area(4));
369369

370370
When an absolute path is given to +require()+, like
371371
+require("/mjsunit.js")+ the module is searched for in the
372-
+node.libraryPaths+ array. +node.libraryPaths+ on my system looks like this:
372+
+require.paths+ array. +require.paths+ on my system looks like this:
373373

374374
----------------------------------------
375375
[ "/home/ryan/.node_libraries"
@@ -382,7 +382,7 @@ That is, first Node looks for +"/home/ryan/.node_libraries/mjsunit.js"+ and
382382
then for +"/home/ryan/local/node/lib/node_libraries/mjsunit.js"+. If not
383383
found, it finally looks for +"/mjsunit.js"+ (in the root directory).
384384

385-
+node.libraryPaths+ can be modified at runtime by simply unshifting new
385+
+require.paths+ can be modified at runtime by simply unshifting new
386386
paths on to it and at startup with the +NODE_LIBRARY_PATHS+ environmental
387387
variable (which should be a list of paths, colon separated).
388388

src/node.js

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ node.Module.prototype.loadScript = function (loadPromise) {
294294
return requireAsync(url).wait();
295295
}
296296

297+
require.paths = node.libraryPaths;
297298
require.async = requireAsync;
298299

299300
// create wrapper function

test/mjsunit/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exports.testDir = node.path.dirname(__filename);
22
exports.fixturesDir = node.path.join(exports.testDir, "fixtures");
33
exports.libDir = node.path.join(exports.testDir, "../../lib");
44

5-
node.libraryPaths.unshift(exports.libDir);
5+
require.paths.unshift(exports.libDir);
66

77
var mjsunit = require("/mjsunit.js");
88
var utils = require("/utils.js");

test/mjsunit/test-buffered-file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ node.mixin(require("common.js"));
33
var testTxt = node.path.join(fixturesDir, "test.txt");
44

55
var libDir = node.path.join(testDir, "../../lib");
6-
node.libraryPaths.unshift(libDir);
6+
require.paths.unshift(libDir);
77
node.mixin(require("/file.js"));
88

99
var fileUnlinked = false;

0 commit comments

Comments
 (0)