0
0
mirror of https://github.com/tj/n.git synced 2024-11-21 18:48:57 +01:00

Fast track exact auto (#813)

This commit is contained in:
John Gee 2024-09-06 14:07:51 +12:00 committed by GitHub
parent 273a485c9e
commit 426952cf48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 11 deletions

14
bin/n
View File

@ -1205,6 +1205,16 @@ function get_auto_version() {
function get_latest_resolved_version() {
g_target_node=
local version=${1}
# Transform some labels before processing further to allow fast-track for exact numeric versions.
if [[ "${version}" = "auto" ]]; then
get_auto_version || return 2
version="${g_target_node}"
elif [[ "${version}" = "engine" ]]; then
get_engine_version || return 2
version="${g_target_node}"
fi
simple_version=${version#node/} # Only place supporting node/ [sic]
if is_exact_numeric_version "${simple_version}"; then
# Just numbers, already resolved, no need to lookup first.
@ -1259,11 +1269,9 @@ function display_local_versions() {
version="$(display_latest_node_support_alias "${version}")"
match_count=1
elif [[ "${version}" = "auto" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_auto_version || return 2
version="${g_target_node}"
elif [[ "${version}" = "engine" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_engine_version || return 2
version="${g_target_node}"
fi
@ -1310,11 +1318,9 @@ function display_remote_versions() {
version="$(display_latest_node_support_alias "${version}")"
match_count=1
elif [[ "${version}" = "auto" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_auto_version || return 2
version="${g_target_node}"
elif [[ "${version}" = "engine" ]]; then
# suppress stdout logging so lsr layout same as usual for scripting
get_engine_version || return 2
version="${g_target_node}"
fi

View File

@ -7,7 +7,7 @@ services=( fedora-curl ubuntu-wget )
cd "$(dirname "${BIN_DIRECTORY}")" || exit 2
for service in "${services[@]}" ; do
echo "${service}"
docker-compose run --rm "${service}" "bats" "/mnt/test/tests"
docker compose run --rm "${service}" "bats" "/mnt/test/tests"
echo ""
done

View File

@ -1,4 +1,3 @@
version: '2'
services:
ubuntu-curl:
extends:

View File

@ -20,17 +20,17 @@ Run all the tests on a single system:
cd test
npx bats tests
docker-compose run ubuntu-curl bats /mnt/test/tests
docker compose run ubuntu-curl bats /mnt/test/tests
Run single test on a single system::
cd test
npx bats tests/install-contents.bats
docker-compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
docker compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
## Docker Tips
Using `docker-compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.
Using `docker compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.
`bats` is being mounted directly out of `node_modules` into the container as a manual install based on its own install script. This is a bit of a hack, but avoids needing to install `git` or `npm` for a full remote install of `bats`, and means everything on the same version of `bats`.
@ -38,7 +38,7 @@ The containers each have:
* either curl or wget (or both) installed
Using `docker-compose` to run the container adds:
Using `docker compose` to run the container adds:
* specified `n` script mounted to `/usr/local/bin/n`
* `test/tests` mounted to `/mnt/test/tests`
@ -48,7 +48,7 @@ Using `docker-compose` to run the container adds:
So for example:
cd test
docker-compose run ubuntu-curl
docker compose run ubuntu-curl
# in container
n --version
bats /mnt/test/tests