Browse Source

Rename node.libraryPaths to require.paths

to be more inline with CommonJS.
v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
04e53cab90
  1. 2
      benchmark/http_simple.js
  2. 2
      benchmark/process_loop.js
  3. 2
      benchmark/run.js
  4. 2
      benchmark/static_http_server.js
  5. 6
      doc/api.txt
  6. 1
      src/node.js
  7. 2
      test/mjsunit/common.js
  8. 2
      test/mjsunit/test-buffered-file.js

2
benchmark/http_simple.js

@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib"); libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir); require.paths.unshift(libDir);
node.mixin(require("/utils.js")); node.mixin(require("/utils.js"));
http = require("/http.js"); http = require("/http.js");

2
benchmark/process_loop.js

@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib"); libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir); require.paths.unshift(libDir);
node.mixin(require("/utils.js")); node.mixin(require("/utils.js"));
function next (i) { function next (i) {
if (i <= 0) return; if (i <= 0) return;

2
benchmark/run.js

@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib"); libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir); require.paths.unshift(libDir);
node.mixin(require("/utils.js")); node.mixin(require("/utils.js"));
var benchmarks = [ "static_http_server.js" var benchmarks = [ "static_http_server.js"
, "timers.js" , "timers.js"

2
benchmark/static_http_server.js

@ -1,5 +1,5 @@
libDir = node.path.join(node.path.dirname(__filename), "../lib"); libDir = node.path.join(node.path.dirname(__filename), "../lib");
node.libraryPaths.unshift(libDir); require.paths.unshift(libDir);
http = require("/http.js"); http = require("/http.js");
var concurrency = 30; var concurrency = 30;
var port = 8000; var port = 8000;

6
doc/api.txt

@ -73,7 +73,7 @@ more information.
+require(path)+ :: +require(path)+ ::
See the modules section. See the modules section.
+node.libraryPaths+ :: +require.paths+ ::
The search path for absolute path arguments to +require()+. The search path for absolute path arguments to +require()+.
+node.mixin([deep], target, object1, [objectN])+ :: +node.mixin([deep], target, object1, [objectN])+ ::
@ -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 When an absolute path is given to +require()+, like
+require("/mjsunit.js")+ the module is searched for in the +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" [ "/home/ryan/.node_libraries"
@ -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 then for +"/home/ryan/local/node/lib/node_libraries/mjsunit.js"+. If not
found, it finally looks for +"/mjsunit.js"+ (in the root directory). 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 paths on to it and at startup with the +NODE_LIBRARY_PATHS+ environmental
variable (which should be a list of paths, colon separated). variable (which should be a list of paths, colon separated).

1
src/node.js

@ -294,6 +294,7 @@ node.Module.prototype.loadScript = function (loadPromise) {
return requireAsync(url).wait(); return requireAsync(url).wait();
} }
require.paths = node.libraryPaths;
require.async = requireAsync; require.async = requireAsync;
// create wrapper function // create wrapper function

2
test/mjsunit/common.js

@ -2,7 +2,7 @@ exports.testDir = node.path.dirname(__filename);
exports.fixturesDir = node.path.join(exports.testDir, "fixtures"); exports.fixturesDir = node.path.join(exports.testDir, "fixtures");
exports.libDir = node.path.join(exports.testDir, "../../lib"); exports.libDir = node.path.join(exports.testDir, "../../lib");
node.libraryPaths.unshift(exports.libDir); require.paths.unshift(exports.libDir);
var mjsunit = require("/mjsunit.js"); var mjsunit = require("/mjsunit.js");
var utils = require("/utils.js"); var utils = require("/utils.js");

2
test/mjsunit/test-buffered-file.js

@ -3,7 +3,7 @@ node.mixin(require("common.js"));
var testTxt = node.path.join(fixturesDir, "test.txt"); var testTxt = node.path.join(fixturesDir, "test.txt");
var libDir = node.path.join(testDir, "../../lib"); var libDir = node.path.join(testDir, "../../lib");
node.libraryPaths.unshift(libDir); require.paths.unshift(libDir);
node.mixin(require("/file.js")); node.mixin(require("/file.js"));
var fileUnlinked = false; var fileUnlinked = false;

Loading…
Cancel
Save