2019-05-04 09:45:53 +02:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load shared-functions
|
2020-12-21 10:50:54 +01:00
|
|
|
load '../../node_modules/bats-support/load'
|
|
|
|
load '../../node_modules/bats-assert/load'
|
2019-05-04 09:45:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
unset_n_env
|
|
|
|
setup_tmp_prefix
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
rm -rf "${TMP_PREFIX_DIR}"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "n --download 4.9.1" {
|
|
|
|
n --download 4.9.1
|
|
|
|
[ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
|
2024-10-28 02:12:13 +01:00
|
|
|
# Remember, we installed a dummy node so do have a bin/node
|
2019-05-04 09:45:53 +02:00
|
|
|
[ ! -f "${N_PREFIX}/bin/npm" ]
|
|
|
|
[ ! -d "${N_PREFIX}/include" ]
|
|
|
|
[ ! -d "${N_PREFIX}/lib" ]
|
|
|
|
[ ! -d "${N_PREFIX}/shared" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "n --quiet 4.9.1" {
|
|
|
|
# just checking option is allowed, not testing functionality
|
|
|
|
n --quiet 4.9.1
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$(node --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert_equal "${output}" "v4.9.1"
|
2019-05-04 09:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-24 09:50:23 +01:00
|
|
|
# mostly --preserve, but also variations with i/install and lts/numeric
|
|
|
|
@test "--preserve variations # (4 installs)" {
|
|
|
|
local ARGON_VERSION="v4.9.1"
|
|
|
|
local ARGON_NPM_VERSION="2.15.11"
|
|
|
|
local LTS_VERSION="$(display_remote_version lts)"
|
|
|
|
|
|
|
|
n ${ARGON_VERSION}
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$("${N_PREFIX}/bin/node" --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert_equal "$output" "${ARGON_VERSION}"
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$("${N_PREFIX}/bin/npm" --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert_equal "$output" "${ARGON_NPM_VERSION}"
|
2020-02-24 09:50:23 +01:00
|
|
|
|
|
|
|
n --preserve "${LTS_VERSION}"
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$("${N_PREFIX}/bin/node" --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert_equal "$output" "v${LTS_VERSION}"
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$("${N_PREFIX}/bin/npm" --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert_equal "$output" "${ARGON_NPM_VERSION}"
|
2020-02-24 09:50:23 +01:00
|
|
|
|
|
|
|
N_PRESERVE_NPM=1 n "${LTS_VERSION}"
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$("${N_PREFIX}/bin/npm" --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert_equal "$output" "${ARGON_NPM_VERSION}"
|
2020-02-24 09:50:23 +01:00
|
|
|
|
|
|
|
N_PRESERVE_NPM=1 n --no-preserve "${LTS_VERSION}"
|
2020-12-20 04:42:27 +01:00
|
|
|
output="$("${N_PREFIX}/bin/npm" --version)"
|
2020-12-21 10:50:54 +01:00
|
|
|
assert [ "$output" != "${ARGON_NPM_VERSION}" ]
|
2020-02-24 09:50:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-04 09:45:53 +02:00
|
|
|
# ToDo: --arch
|