Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Rename node.libraryPaths to require.paths
Browse files Browse the repository at this point in the history
to be more inline with CommonJS.
  • Loading branch information
ry committed Oct 25, 2009
1 parent 4bcb01c commit 04e53ca
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion benchmark/http_simple.js
@@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir);
require.paths.unshift(libDir);

node.mixin(require("/utils.js"));
http = require("/http.js");
Expand Down
2 changes: 1 addition & 1 deletion benchmark/process_loop.js
@@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir);
require.paths.unshift(libDir);
node.mixin(require("/utils.js"));
function next (i) {
if (i <= 0) return;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/run.js
@@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir);
require.paths.unshift(libDir);
node.mixin(require("/utils.js"));
var benchmarks = [ "static_http_server.js"
, "timers.js"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/static_http_server.js
@@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir);
require.paths.unshift(libDir);
http = require("/http.js");
var concurrency = 30;
var port = 8000;
Expand Down
6 changes: 3 additions & 3 deletions doc/api.txt
Expand Up @@ -73,7 +73,7 @@ more information.
+require(path)+ ::
See the modules section.

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

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

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

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

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

Expand Down
1 change: 1 addition & 0 deletions src/node.js
Expand Up @@ -294,6 +294,7 @@ node.Module.prototype.loadScript = function (loadPromise) {
return requireAsync(url).wait();
}

require.paths = node.libraryPaths;
require.async = requireAsync;

// create wrapper function
Expand Down
2 changes: 1 addition & 1 deletion test/mjsunit/common.js
Expand Up @@ -2,7 +2,7 @@ exports.testDir = node.path.dirname(__filename);
exports.fixturesDir = node.path.join(exports.testDir, "fixtures");
exports.libDir = node.path.join(exports.testDir, "../../lib");

node.libraryPaths.unshift(exports.libDir);
require.paths.unshift(exports.libDir);

var mjsunit = require("/mjsunit.js");
var utils = require("/utils.js");
Expand Down
2 changes: 1 addition & 1 deletion test/mjsunit/test-buffered-file.js
Expand Up @@ -3,7 +3,7 @@ node.mixin(require("common.js"));
var testTxt = node.path.join(fixturesDir, "test.txt");

var libDir = node.path.join(testDir, "../../lib");
node.libraryPaths.unshift(libDir);
require.paths.unshift(libDir);
node.mixin(require("/file.js"));

var fileUnlinked = false;
Expand Down

0 comments on commit 04e53ca

Please sign in to comment.