-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Add CLI option to set where to get the node version from, other than /.nvmrc
#3234
Comments
As I'm still learning how the codebase works, and as the CLI flag option looks better (since deciding to use the To set nvm_find_up() {
local path_
path_="${PWD}"
while [ "${path_}" != "" ] && [ "${path_}" != '.' ] && [ ! -f "${path_}/${1-}" ] && [ ! -f "${path_}/config/nvm/${1-}" ]; do
path_=${path_%/*}
done
nvm_echo "${path_}"
}
nvm_find_nvmrc() {
local dir
dir="$(nvm_find_up '.nvmrc')"
if [ -e "${dir}/.nvmrc" ]; then
nvm_echo "${dir}/.nvmrc"
elif [ -e "${dir}/config/nvm/.nvmrc" ]; then
nvm_echo "${dir}/config/nvm/.nvmrc"
fi
} |
I personally think that's a fruitless quest; many tools aren't configurable in that way, and I'm not all that interested in making nvm more complex in pursuit of that goal. |
I do agree that many tools are not—but the most widely-used ones are. Look at typescript (the It's not that difficult to add the flag, I've already opened a PR, look at #3235. |
By "complexity" i don't mean difficulty to add - flags are trivial - but more logic present in the code, more to maintain, more chance of bugs. TS and prettier and eslint are very different kinds of tools with very large config files that often need to be managed by different teams than those using them, and that often need to compose with other config files. They're just not in the same arena as nvm's very simple line-based config file (that only currently supports a single value). nvm commands are often run in succession; are you really going to want to append |
I personally do not find the added logic to add that much complexity, but if you think so then it's fine—you are the one mostly maintaining the project after all. I do not fully agree with claiming that just because the config is small, then it's not worth having it modular in this way. It is a similar discussion to the Regarding the length of the command: yes it could be an annoyance, but... The proposed solution is 100% backwards compatible with the current way of doing things: those who have an The flag is not forced upon people, so if you don't need to tuck the config away in a separate place, one does not have to do so. But for those that need/want to do so fully acknowledge that they have to type in the flag every time they run the code (but one could also add a script to their |
"cluttered" is an opinion, not a fact; having config files in the root means they're exactly where everyone expects to find them, precisely because neither XDG nor "config/" nor anything else is a universal, or even majority, setup. I definitely agree it's backwards compatible, which is good and necessary. What happens, though, when there's an |
In my opinion this is how it should be done:
In this case it means that:
This way we make sure that the user gets what they expect: those that want a custom config use that, those that do not care can place the config in either location, and those that do not want to change anything can keep doing things as things have always been done before. |
as a side note, nvm won’t ever have more than one local config file; a directory for them seems overkill. By default i wouldn’t want any “new” location, either. |
Well than the case is even more simple: just look for the "usual" Code-wise it's basically all done in the PR I made. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Supporting a different file format like node-version is off topic here; see #794. @victormihalache i agree that just adding the flag with no other changes is technically trivial; I’m just not convinced it’s a valuable enough feature to add. In software, yes is permanent and no is temporary, so adding things must always be treated as more dangerous than declining a feature request. I’m going to leave this open until I’ve decided one way or another, as closing it would mean we’d never add it. |
This comment was marked as spam.
This comment was marked as spam.
Would there be any downside to allowing the user to chose the path they best prefer? |
The downsides could include:
and i'm sure all sorts of other unknowns. The first of these applies to any new feature ofc. |
Still don't get how having an optional way to select a path will break anyone's workflow. If you want a path other than |
It won't break anyone's workflow who doesn't use that option, certainly! The issue is that by using the option, you're potentially (likely) breaking other people's workflows. |
In my quest to try and have a clean root for my project, I have moved most of my config files to a
config
folder. I was able to do so because I could specify to the various tools that their config file was located there via a CLI option like--config <path>
.nvm
does not provide a way to set such path. It would be handy to be able to run something likenvm use --config config/nvm
ornvm use -c config/nvm
and read the given file like it would read.nvmrc
.To further expand, one could put a
.nvmrc
file in a folder—sayconfig
—such that when the-c
option is used by just giving the path to a folder, likenvm use -c config
, it would look for a.nvmrc
in that folder. Or, even better in my opinion, have it search for more than just/.nvmrc
(personal taste,./config/nvm/config
would be the best).The text was updated successfully, but these errors were encountered: