[Refactor] add nvm_get_artifact_compression

This commit is contained in:
nmarghetti
2021-01-02 00:03:24 +01:00
committed by Jordan Harband
parent a5742d4e9e
commit d396181ffb
3 changed files with 40 additions and 10 deletions

View File

@@ -0,0 +1,16 @@
#!/bin/sh
cleanup () {
unset -f die cleanup
}
die () { echo "$@" ; cleanup ; exit 1; }
\. ../../../nvm.sh
# nvm_get_artifact_compression by default
[ "$(nvm_get_artifact_compression)" = 'tar.gz' ] || die 'nvm_get_artifact_compression should return "tar.gz" by default'
# nvm_get_artifact_compression with xz
[ "$(nvm_get_artifact_compression "14.0.0")" = 'tar.xz' ] || die 'nvm_get_artifact_compression should return "tar.xz" for this version'
cleanup

View File

@@ -31,14 +31,14 @@ nvm_download() {
nvm_get_checksum_alg() {
echo 'sha-256'
}
OUTPUT="$(nvm_get_checksum node std foo bar baz)"
OUTPUT="$(nvm_get_checksum node std foo bar tar.baz)"
EXPECTED_OUTPUT="mirror-node-std/foo/SHASUMS256.txt"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
nvm_get_checksum_alg() {
echo 'sha-1'
}
OUTPUT="$(nvm_get_checksum iojs std foo bar baz)"
OUTPUT="$(nvm_get_checksum iojs std foo bar tar.baz)"
EXPECTED_OUTPUT="mirror-iojs-std/foo/SHASUMS.txt"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"