Skip to content
Myr

Add `nvm_get_checksum_alg`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jordan Harband · committed by Jordan Harband · parent bd3ca47 · Browse files · 2 files+47 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+47 added−0 removed

  • tests:+18 added−0 removed
  • other:+29 added−0 removed

2 files+47 added−0 removed

added:test/fast/Unit tests/nvm_get_checksum_alg+18 added
1#!/bin/sh23set -ex45die () { echo $@ ; exit 1; }67. ../../../nvm.sh89ALG="$(nvm_get_checksum_alg)"1011case "$ALG" in12 'sha-256' | 'sha-1')13 echo 'sha-256 or sha-1 found'14 ;;15 *)16 die "sha-256 or sha-1 not found: found ${ALG}"17 ;;18esac
modified:nvm.sh+29 added
1000 unmodified lines
1001 fi1002 nvm_echo "${VERSIONS}"1003}10041005nvm_get_checksum_alg() {1006 if nvm_has "sha256sum" && ! nvm_is_alias "sha256sum"; then1007 nvm_echo 'sha-256'1008 elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then1009 nvm_echo 'sha-256'1010 elif nvm_has "sha256" && ! nvm_is_alias "sha256"; then1011 nvm_echo 'sha-256'1012 elif nvm_has "gsha256sum" && ! nvm_is_alias "gsha256sum"; then1013 nvm_echo 'sha-256'1014 elif nvm_has "openssl" && ! nvm_is_alias "openssl"; then1015 nvm_echo 'sha-256'1016 elif nvm_has "libressl" && ! nvm_is_alias "libressl"; then1017 nvm_echo 'sha-256'1018 elif nvm_has "bssl" && ! nvm_is_alias "bssl"; then1019 nvm_echo 'sha-256'1020 elif nvm_has "sha1sum" && ! nvm_is_alias "sha1sum"; then1021 nvm_echo 'sha-1'1022 elif nvm_has "sha1" && ! nvm_is_alias "sha1"; then1023 nvm_echo 'sha-1'1024 elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then1025 nvm_echo 'sha-1'1026 else1027 nvm_err 'Unaliased sha256sum, shasum, sha256, gsha256sum, openssl, libressl, or bssl not found.'1028 nvm_err 'Unaliased sha1sum, sha1, or shasum not found.'1029 return 11030 fi1031}10321033nvm_checksum() {1034 local NVM_CHECKSUM1035 if [ -z "${3-}" ] || [ "${3-}" = 'sha1' ]; then1036 if nvm_has "sha1sum" && ! nvm_is_alias "sha1sum"; then
1839 unmodified lines
2876 nvm_ls nvm_remote_version nvm_remote_versions \2877 nvm_install_iojs_binary nvm_install_node_binary \2878 nvm_install_merged_node_binary \2879 nvm_install_node_source nvm_check_file_permissions \2880 nvm_get_checksum_alg \2881 nvm_version nvm_rc_version nvm_match_version \2882 nvm_ensure_default_set nvm_get_arch nvm_get_os \2883 nvm_print_implicit_alias nvm_validate_implicit_alias \2884 nvm_resolve_alias nvm_ls_current nvm_alias \
80 unmodified lines