Skip to content
Myr

nvm_install_binary_extract

This file

Path

test/fast/Unit tests/nvm_install_binary_extract

71 lines · 1.7 KiB

Last changed by

[Tests] set `$_` before sourcing `nvm.sh` in fast testsJordan Harbandbefore adoptionc451e7a

History of this file

Take it

The walk stopped after 200 commits: lines older than 5c12680 point at it.

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 1–42why, one step back
1#!/bin/sh
23cleanup() {4 [ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}"5 [ -d "${NVM_DIR}" ] && rm -rf "${NVM_DIR}"6 unset -f die cleanup test_archi nvm_supports_xz7 unset NVM_DIR tmp_dir version archi8}910die() { echo "$@" ; cleanup ; exit 1; }1112test_archi() {13 local os14 os="$1"15 local version16 version="$2"17 local archi18 archi="$os-$3"19 local node20 node="$4"21 local ext22 ext="$5"23 local command24 command="$6"25 local command_option26 command_option="$7"27 local node_dir28 node_dir="${tmp_dir}/node-${version}-${archi}"29 local node_path30 node_path="${node_dir}/${node}"3132 # Create tarball33 mkdir -p "$(dirname "${node_path}")"34 echo "node ${version}" > "${node_path}"35 (cd "${tmp_dir}" && "${command}" "${command_option}" "${node_dir}.${ext}" "node-${version}-${archi}")36 [ -f "${node_dir}.${ext}" ] || die "Unable to create fake ${ext} file"3738 # Extract it39 nvm_install_binary_extract "$os" "$version" "$(expr "${version}" : '.\(.*\)')" "${node_dir}.$ext" "${tmp_dir}/files"40 [ "$(cat "${NVM_DIR}/versions/node/${version}/bin/node")" = "node ${version}" ] || die "Unable to extract ${ext} file"41}42

[Tests] set `$_` before sourcing `nvm.sh` in fast testsJordan Harbandbefore adoptionc451e7a

line 43why, one step back
43: nvm.sh

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 44–71why, one step back
44\. ../../../nvm.sh
4546set -ex4748# nvm_install_binary_extract is available49type nvm_install_binary_extract > /dev/null 2>&1 || die 'nvm_install_binary_extract is not available'5051NVM_DIR=$(mktemp -d)52tmp_dir=$(mktemp -d)53if [ -z "${NVM_DIR}" ] || [ -z "${tmp_dir}" ]; then54 die 'Unable to create temporary folder'55fi5657# Test windows zip58# TODO: enable this59# test_archi 'win' 'v15.6.0' 'x64' 'node' 'zip' 'zip' '-qr'6061# Test linux tar.xz62test_archi 'linux' 'v14.15.4' 'x64' 'bin/node' 'tar.xz' 'tar' '-cJf'6364nvm_supports_xz() {65 return 166}6768# Test linux tar.gz69test_archi 'linux' 'v12.9.0' 'x64' 'bin/node' 'tar.gz' 'tar' '-czf'7071cleanup