node-info 719 B

123456789101112131415161718192021222324252627282930313233
  1. #
  2. # Exposes information about the Node.js environment via the $node_info
  3. # associative array.
  4. #
  5. # Authors:
  6. # Zeh Rizzatti <zehrizzatti@gmail.com>
  7. #
  8. # function node-info {
  9. local version
  10. local version_format
  11. local version_formatted
  12. unset node_info
  13. typeset -gA node_info
  14. if (( $+commands[nodenv] )); then
  15. version="${${$(nodenv version)#v}[(w)0]}"
  16. elif (( $+functions[nvm_version] )); then
  17. version="${$(nvm_version)#v}"
  18. elif (( $+commands[node] )) ; then
  19. version="${$(node -v)#v}"
  20. fi
  21. if [[ "$version" != (none|system) ]]; then
  22. zstyle -s ':prezto:module:node:info:version' format 'version_format'
  23. zformat -f version_formatted "$version_format" "v:$version"
  24. node_info[version]="$version_formatted"
  25. fi
  26. # }