Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NODE_PATH in forked process #531

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function Api(files, options) {
}, this);

this._reset();

if (process.env.NODE_PATH) {
process.env.NODE_PATH = path.join(process.cwd(), process.env.NODE_PATH);
}
}

util.inherits(Api, EventEmitter);
Expand Down
3 changes: 3 additions & 0 deletions lib/test-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ var oldNodeModulesPaths = module.constructor._nodeModulePaths;
module.constructor._nodeModulePaths = function () {
var ret = oldNodeModulesPaths.apply(this, arguments);
ret.push(nodeModulesDir);
if (process.env.NODE_PATH) {
ret.push(process.env.NODE_PATH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NODE_PATH can contain multiple values. Not sure if the env var needs to be split and concatenated with ret here. See https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders for more.

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could replace with:

return ret.concat(nodeModulesDir, additionalPaths);

return ret;
};

Expand Down