-
-
Notifications
You must be signed in to change notification settings - Fork 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
[New] nvm use
/nvm install
: add --save
option
#2869
Conversation
Fixes nvm-sh#2849. Co-authored-by: Martin <[email protected]> Co-authored-by: Jordan Harband <[email protected]>
--save
option for nvm use
and nvm install
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.
Let's add a bunch more tests - here's some example input:
nvm use --save --lts
nvm use --save lts/argon
nvm use --save lts/*
nvm use --save node
nvm use --save iojs
nvm use --save foo
(wherefoo
is a custom user alias)nvm use --save
(where the version is read from a.nvmrc
in a higher directory)
Let's also add some error tests for the cases where the .nvmrc
file fails to be written (no permissions in the current directory, or the disk is full, for example)
Thanks for all the advice, it's been really helpful! |
If you can make them be "fast" tests, then one file is totally fine - mainly it'll depend on how much setup is required. Generally each test file should only have one batch of setup at the beginning, and one batch of cleanup at the end. |
test/slow/nvm use/Running 'nvm use --save --lts' should work as expected
Outdated
Show resolved
Hide resolved
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.
The nvm install
and nvm use
tests should definitely be in separate files.
Also, could the tests all be moved to fast
? they'd be able to use mocks for nvm ls-remote
calls, and as long as the dynamically-looked-up expected versions were fake-installed already, then they wouldn't need to actually install anything.
test/slow/nvm use/Running 'nvm use --save --lts' should work as expected
Outdated
Show resolved
Hide resolved
test/slow/nvm use/Running 'nvm use --save --lts' should work as expected
Outdated
Show resolved
Hide resolved
test/slow/nvm use/Running 'nvm use --save --lts' should work as expected
Outdated
Show resolved
Hide resolved
test/slow/nvm use/Running 'nvm use --save --lts' should work as expected
Outdated
Show resolved
Hide resolved
test/slow/nvm use/Running 'nvm use --save --lts' should work as expected
Outdated
Show resolved
Hide resolved
I've moved all of the test to 'fast' and split them into different files, however I'm not sure how to do fake installs (have you got any existing functions to do that?) |
test/fast/Running 'nvm install --save --lts' with incorrect file permissions fails nicely
Outdated
Show resolved
Hide resolved
i do! grep for |
Hmm, I tried that (from |
If you'd like I can prepend that to all of the |
ah right, the other piece is that you have to mock out |
I'm not quite sure how to mock |
I added the mocks; I think this might be good to go! It'll have to wait until the broken travis tests on master are fixed; please keep the fork/branch undeleted and the PR open until then :-) |
--save
option for nvm use
and nvm install
nvm use
/nvm install
: add --save
option
67ab6bb
to
a40bfed
Compare
@ljharb The issue with the tests was that I was using |
b226e57
to
2519281
Compare
Just pushed again with a 3 more things:
|
yeah, that's fine - sometimes i have to setting -e isn't even really a good practice anymore, so i'm not too worried about it. good to set it in tests if possible tho :-) |
Just rebased again if you think this is ready to merge? |
Unfortunately the Travis tests are still failing - https://app.travis-ci.com/github/nvm-sh/nvm/jobs/619295015 |
28ebb07
to
4375ca3
Compare
@ljharb There was only one issue which was surprisingly simple to fix, but annoying to figure out - I just needed to add a couple of extra bits to the cleanup () {
nvm cache clear
nvm deactivate
nvm unalias default
rm -rf ${NVM_DIR}/v* .nvmrc
if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi
unset -f nvm_ls_remote nvm_ls_remote_iojs
} |
@maartin0 sorry for the delay here; can you please rebase this and resolve the conflicts? |
@ljharb All done and no worries, although Travis seems to have another issue?
|
yep, known and don’t worry about that one :-) |
c6cfc3a
to
c20db2a
Compare
In this PR I've:
--save
option as pernvm use
should write a.nvmrc
file by default #2849nvm use
andnvm install
(which actually just carries over the option)bash
,sh
andzsh
Fixes #2849