Skip to content
Myr

Merge pull request #512 from kevinwang/shasum-lowest-priority

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

Make shasum the lowest priority checksum command.

authored by Jordan Harband · committed by Jordan Harband · parents b61445c, e8056ac · Browse files · 2 files+21 added−3 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+21 added−3 removed

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

2 files+21 added−3 removed

added:test/fast/Unit tests/nvm_checksum+18 added
1#!/bin/sh23cleanup () {4 rm tmp/emptyfile tmp/testfile5 rmdir tmp6}7die () { echo $@ ; cleanup; exit 1; }89. ../../../nvm.sh1011mkdir -p tmp12touch tmp/emptyfile13echo -n "test" > tmp/testfile1415nvm_checksum tmp/emptyfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" || die "nvm_checksum on an empty file did not match the SHA1 digest of the empty string"16nvm_checksum tmp/testfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" && die "nvm_checksum allowed a bad checksum"1718cleanup
modified:nvm.sh+3 added-3 removed
282 unmodified lines
283 return284}285286nvm_checksum() {287 if nvm_has "shasum"; then288 checksum=$(shasum $1 | \awk '{print $1}')287 if nvm_has "sha1sum"; then288 checksum=$(sha1sum $1 | \awk '{print $1}')289 elif nvm_has "sha1"; then290 checksum=$(sha1 -q $1)291 else292 checksum=$(sha1sum $1 | \awk '{print $1}')292 checksum=$(shasum $1 | \awk '{print $1}')293 fi294295 if [ "$checksum" = "$2" ]; then296 return
523 unmodified lines