-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Allow use of NVM_AUTO_USE alongside NVM_LAZY_LOAD on init #55
Open
runofthemill
wants to merge
6
commits into
lukechilds:master
Choose a base branch
from
runofthemill:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6ee0910
Allow use of NVM_AUTO_USE alongside NVM_LAZY_LOAD
runofthemill 6557d7e
Add failing test for auto and lazy
amirdt22 d68eed6
Merge pull request #1 from amirdt22/auto-lazy
runofthemill 8df3e2b
remove extraneous _zsh_nvm_auto_use call
runofthemill 9212aaf
helps to init lazy loader for this test
0b1344d
also helps to escape quotes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
source ../common.sh | ||
|
||
# Node.js version to install | ||
node_version=v5.11.0 | ||
|
||
# Load zsh-nvm and install Node.js in subshell | ||
(load_zsh_nvm && nvm install "$node_version" && [[ "$(node --version)" == "$node_version" ]]) || die "node wasn't installed" | ||
|
||
# Check node isn't available | ||
[[ "$(node --version)" != "$node_version" ]] || die "node shouldn't be available $(node --version)" | ||
|
||
# Setup .nvmrc dir | ||
local nvmrc_dir="$test_dir/nvmrc2" | ||
local no_nvmrc_dir="$test_dir/no-nvmrc2" | ||
local nvmrc="$nvmrc_dir/.nvmrc" | ||
mkdir "$no_nvmrc_dir" | ||
mkdir "$nvmrc_dir" | ||
touch "$nvmrc" | ||
|
||
# Set NVM_LAZY_LOAD to true | ||
export NVM_LAZY_LOAD=true | ||
export NVM_AUTO_USE=true | ||
|
||
# Load zsh-nvm | ||
load_zsh_nvm | ||
|
||
# Check nvm is a lazy load function | ||
[[ $(which nvm) == *"_zsh_nvm_load"* ]] || die "nvm should be a lazy load function" | ||
|
||
# Check node is a lazy load function | ||
[[ $(command -v node) == "node" ]] || die "node should be a shell function" | ||
|
||
# Check npm is a lazy load function | ||
[[ $(command -v npm) == "npm" ]] || die "npm should be a shell function" | ||
|
||
# Init lazy loader | ||
node --version || die "couldn't run lazy loader" | ||
|
||
# Check nvm is not a lazy load function | ||
[[ $(which nvm) != *"_zsh_nvm_load"* ]] || die "nvm should not be a lazy load function" | ||
|
||
# Check node is a binary | ||
[[ "$(command -v node)" == "$(nvm_version_path $node_version)/bin/node" ]] || die "node should now be a binary" | ||
|
||
# Check npm is a binary | ||
[[ "$(command -v npm)" == "$(nvm_version_path $node_version)/bin/npm" ]] || die "npm should now be a binary" | ||
|
||
# Check cd into folder with .nvmrc keeps v6 | ||
echo 6 > "$nvmrc" | ||
(cd "$nvmrc_dir" && [[ "$(node --version | tail -1)" == "v6."* ]]) || die "Didn't switch to node 6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need to setup the
chpwd
hook here?Shouldn't it already be set here?
https://github.com/lukechilds/zsh-nvm/pull/55/files#diff-dfc5680d74f94037e00d26cbeba9485eR212
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 tests all still pass if this line is removed:
https://travis-ci.org/github/lukechilds/zsh-nvm/jobs/687714916
30f8555
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 is what you should do here:
The hooks are already loaded, you just need to run _zsh_nvm_auto_use after loading nvm