diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2015-05-27 10:11:30 -0700 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2015-05-30 10:36:09 -0400 |
commit | 5759722cfacf17cc79651c81801a5e03521db053 (patch) | |
tree | b4bb49403e7346dd166f64820ef7e2adff284a85 /test | |
parent | 53e98cc1b44203147c0abdc03eb0e57e34c4274d (diff) | |
download | nodejs-5759722cfacf17cc79651c81801a5e03521db053.tar.gz nodejs-5759722cfacf17cc79651c81801a5e03521db053.tar.bz2 nodejs-5759722cfacf17cc79651c81801a5e03521db053.zip |
src: fix module search path for preload modules
When the preload module is not a abs/relative path, we should use
the standard search mechanism of looking into the node_modules folders
outwards. The current working directory is deemed to be the 'requiring
module', i.e. parent. The search path starts from cwd outwards.
Fixes: https://github.com/nodejs/io.js/issues/1803
PR-URL: https://github.com/nodejs/io.js/pull/1812
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/cluster-preload.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/fixtures/cluster-preload.js b/test/fixtures/cluster-preload.js index 651fc480e..3063e5b77 100644 --- a/test/fixtures/cluster-preload.js +++ b/test/fixtures/cluster-preload.js @@ -1,3 +1,12 @@ +var assert = require('assert'); + +// https://github.com/nodejs/io.js/issues/1803 +// this module is used as a preload module. It should have a parent with the +// module search paths initialized from the current working directory +assert.ok(module.parent); +var expectedPaths = require('module')._nodeModulePaths(process.cwd()); +assert.deepEqual(module.parent.paths, expectedPaths); + var cluster = require('cluster'); cluster.isMaster || process.exit(42 + cluster.worker.id); // +42 to distinguish // from exit(1) for other random reasons |