-
-
Notifications
You must be signed in to change notification settings - Fork 10
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 the use of Node.js as an npm dependency #8
Conversation
This will help allow users to force a particular node version to be used, even if there is already one on the path.
Common pattern is to use node as a devDependency in an npm package so that everything uses that version of node; if it's present, run-node should probably use that as well. Unless told not to. Which can be done by specifying the RUN_NODE_CACHE_PATH, in which case that file will be sourced to update the PATH. Or, you can do so by having a local .node_path file, which will be sourced if present (and RUN_NODE_CACHE_PATH is not defined).
I'm ok with the first two changes, but I don't really want the |
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.
Got it; I'll remove the local node_path, fix the tabs, and update the README.
I believe I made the changes as requested, please let me know if there are any other changes you'd like me to make =) |
A common pattern in npm projects is to specify node as a dependency or devDependency in order to make sure that npm scripts are run with the desired node version. Changes in this pull request will prioritize looking for the presence of an installed
./node_modules/node
dependency and use that version if found. I propose that this is the preferred behavior for users, but it is technically breaking backward compatibility because existing uses that happen to have node installed as a dependency will now behave differently.Two other changes are also rolled into this PR, though they could be separated if they aren't desired. One is that if
RUN_NODE_CACHE_PATH
is defined and the specified path cache file exists, then it is sourced immediately, instead of waiting to see if node is already found on the existing path. This allows a user to use the env var to override the system path with a custom path cache, which is helpful if their PATH already contains a node executable, but not the one they want to us.The other change is to allow for a local
.node_path
file which can also be used to override the system path to use a specific node version: if this file is present (andRUN_NODE_CACHE_PATH
is not defined), it will likewise be sourced immediately before checking for the presence of a node command.