-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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 Volta Support #2100
Open
adamavenir
wants to merge
7
commits into
sorin-ionescu:master
Choose a base branch
from
adamavenir:feature/add-volta-support
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.
+50
−24
Open
Add Volta Support #2100
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6f38c9c
feat: Add Volta support to Node module
adamavenir b0ef5e1
feat: update requirements check to include volta
adamavenir c257740
feat: update requirements check to include volta
adamavenir 5291eae
feat: add volta support to node-info function
adamavenir 9d89a67
fix: update Volta version parsing to match current output format
adamavenir 0d64389
feat: add node version to sorin prompt
adamavenir 0e24b6b
check for node project
adamavenir 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 |
---|---|---|
|
@@ -6,27 +6,32 @@ | |
# Zeh Rizzatti <[email protected]> | ||
# | ||
|
||
# function node-info { | ||
|
||
local version | ||
local version_format | ||
local version_formatted | ||
|
||
unset node_info | ||
typeset -gA node_info | ||
|
||
if (( $+commands[nodenv] )); then | ||
version="${${$(nodenv version)#v}[(w)0]}" | ||
elif (( $+functions[nvm_version] )); then | ||
version="${$(nvm_version)#v}" | ||
elif (( $+commands[node] )) ; then | ||
version="${$(node -v)#v}" | ||
fi | ||
|
||
if [[ "$version" != (none|system) ]]; then | ||
# Only proceed if we're in a Node.js project | ||
if [[ -f "package.json" || -f ".nvmrc" || -f ".node-version" ]]; then | ||
# Get the format | ||
zstyle -s ':prezto:module:node:info:version' format 'version_format' | ||
zformat -f version_formatted "$version_format" "v:$version" | ||
node_info[version]="$version_formatted" | ||
fi | ||
|
||
# } | ||
if [[ -n "$version_format" ]]; then | ||
if (( $+commands[nodenv] )); then | ||
version="${${$(nodenv version)#v}[(w)0]}" | ||
elif (( $+commands[volta] )); then | ||
version="${${$(volta list node | grep 'default')#*@}%% *}" | ||
elif (( $+functions[nvm_version] )); then | ||
version="${$(nvm_version)#v}" | ||
elif (( $+commands[node] )) ; then | ||
version="${$(node -v)#v}" | ||
fi | ||
|
||
if [[ -n "$version" && "$version" != "system" ]]; then | ||
zformat -f version_formatted "$version_format" "v:$version" | ||
node_info[version]="$version_formatted" | ||
fi | ||
fi | ||
fi |
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 |
---|---|---|
|
@@ -8,19 +8,23 @@ | |
# Indrajit Raychaudhuri <[email protected]> | ||
# | ||
|
||
# Possible lookup locations for manually installed nodenv and nvm. | ||
# Possible lookup locations for manually installed version managers | ||
local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N)) | ||
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N)) | ||
local_volta_paths=({$VOLTA_HOME,$HOME/.volta}/bin/volta(N)) | ||
|
||
# Load manually installed or package manager installed nodenv into the shell | ||
# session. | ||
if (( $#local_nodenv_paths || $+commands[nodenv] )); then | ||
|
||
# Ensure manually installed nodenv is added to path when present. | ||
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path) | ||
|
||
eval "$(nodenv init - zsh)" | ||
|
||
# Use volta if it's installed | ||
elif (( $#local_volta_paths || $+commands[volta] )); then | ||
export VOLTA_HOME="${VOLTA_HOME:-$HOME/.volta}" | ||
path=("$VOLTA_HOME/bin" $path) | ||
|
||
# Load manually installed nvm into the shell session. | ||
elif (( $#local_nvm_paths )); then | ||
source "$local_nvm_paths[1]" --no-use | ||
|
@@ -31,10 +35,10 @@ elif (( $+commands[brew] )) \ | |
source "$nvm_path/nvm.sh" --no-use | ||
fi | ||
|
||
unset local_n{odenv,vm}_paths nvm_path | ||
unset local_{nodenv,nvm,volta}_paths nvm_path | ||
|
||
# Return if requirements are not found. | ||
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then | ||
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] && ! $+commands[volta] )); then | ||
return 1 | ||
fi | ||
|
||
|
@@ -64,4 +68,12 @@ if ! zstyle -t ':prezto:module:node:alias' skip; then | |
alias npmci='npm ci' | ||
alias npmcit='npm cit' | ||
alias npmit='npm it' | ||
fi | ||
|
||
# Add Volta-specific aliases if Volta is installed | ||
if (( $+commands[volta] )); then | ||
alias vl='volta list' | ||
alias vla='volta list all' | ||
alias vi='volta install' | ||
alias vp='volta pin' | ||
fi | ||
fi |
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.
Almost every *nix out there has
vi
as editor command. Also chances are many users just typevi
without thinking and expect the editor to show up on the screen.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.
lol yes I am actually a vim user and just wasn't thinking 😆
I type out
volta install
myself and was actually just following the existing pattern. I'll make a change to have more sensible aliases here.