-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Feature request: script-friendly output of nvm ls, ls-remote, alias #2005
Comments
Here's what's problematic about the current output:
And so on. It's no fun. |
Of course, different scripts have different requirements. Some scripts may need...
Such scripts could probably combine and filter the output of But maybe a less simplistic format would make life easier for such scripts:
Which columns would make sense? I don't know enough about the data currently produced by
|
Maybe it would be nice to have multiple options for the output, e.g. |
As you said, different scripts have different requirements. The no-colors version is what I’d build off of; the asterisks are necessary so scripts and humans can know which is installed. You can use Since aliases can be most any string, it’s important to see what they resolve to - it wouldn’t be useful to just list the alias, or just the resolved value. Can you elaborate on precisely what you want to do that you find hard? |
(also note your ls workaround is not robust; not everything is in the versions folder or the versions/node folder) |
I tried to solve #1792: uninstall all x.* versions. In my case, I had installed about twenty different versions (from 0.x to 10.x) because I had run compatibility tests and now wanted to delete most of them. I looked at the output of
Of course, it's possible to handle all of these things in a script, but it's rather awkward. For example, cut doesn't work because the version number is preceded by a variable number of spaces. I could first pipe the ouput of But anyway, I tried again and came up with a pipeline that seems to extract version numbers from the output of
Not too bad, but... I guess my point is that almost all UNIX shell commands are made to play well with scripts. For example, |
|
If you can write a PR that can detect when |
I found this on Stack Overflow. Seems to work on my machine (macOS 10.13.6, tested in GNU bash 3.2.57 and zsh 5.3): test_term() {
local IS_TERMINAL
if [ -t 1 ]; then
IS_TERMINAL=true
fi
echo $IS_TERMINAL
} Result: I'd be happy to create a PR, but I'm not sure where to put this in nvm.sh. I guess a function like nvm_is_terminal() {
[ -t 1 ]
} I created PR #2007. Let me know what you think. |
Auto-switching the format of many nvm commands sounds great. As you mentioned at #1792, it would probably be best to have a |
Please file a new issue if your needs still aren't met :-) |
While trying to write a bash script that solves #1792, I noticed that it's not easy to process the output of
nvm ls
ornvm ls-remote
. It would be nice to have an option to make these commands produce output that is suitable for scripts.Maybe something like this:
nvm ls
should listN/A
)nvm ls-remote
should list(LTS: Dubnium)
)In the case of
nvm ls
, there's a simple workaround that should work in many cases: just usels -1 ~/.nvm/versions/node/
instead. But there's no such workaround fornvm ls-remote
andnvm alias
.The text was updated successfully, but these errors were encountered: