-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Support NODE_PATH in forked process #531
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
Changes from 4 commits
c2aab4f
3704a07
33dd8f6
669be7c
d37a356
082708b
d4bf3ee
1e2d8ad
eecfebb
c42afed
581e776
5dc109e
f947eb0
f932f07
d2fa2a2
efdc4c2
75b0de0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,12 @@ var oldNodeModulesPaths = module.constructor._nodeModulePaths; | |
module.constructor._nodeModulePaths = function () { | ||
var ret = oldNodeModulesPaths.apply(this, arguments); | ||
ret.push(nodeModulesDir); | ||
if (process.env.NODE_PATH) { | ||
var osSplitChar = /^win/.test(process.platform) ? ';' : ','; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps use
The non-Windows separators are colons, not commas. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to add another dependency, but if it's fine for you I think too that this would be a better solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is, but I don't have final say ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to use process.platform === 'win32' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh yea, fair enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I guess I could leave the test as it is (except for the wrong separators). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
process.env.NODE_PATH.split(osSplitChar).forEach(function (additionalPath) { | ||
ret.push(path.join(opts.projectRoot, additionalPath)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah you're right, I'm really bad at this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries! This stuff is maddeningly difficult. |
||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could replace with: return ret.concat(nodeModulesDir, additionalPaths); |
||
return ret; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily the project root. Perhaps
parentWorkingDirectory
? Bit verbose though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
parentCwd
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure