mirror of
https://github.com/tj/n.git
synced 2024-11-24 11:27:29 +01:00
Add download command (#821)
This commit is contained in:
parent
eea2a55533
commit
cbde6e2b01
@ -234,6 +234,10 @@ List downloaded versions in cache:
|
|||||||
|
|
||||||
n ls
|
n ls
|
||||||
|
|
||||||
|
Download version into cache:
|
||||||
|
|
||||||
|
n download 22
|
||||||
|
|
||||||
Use `n` to access cached versions (already downloaded) without internet available.
|
Use `n` to access cached versions (already downloaded) without internet available.
|
||||||
|
|
||||||
n --offline 12
|
n --offline 12
|
||||||
|
10
bin/n
10
bin/n
@ -390,6 +390,7 @@ Commands:
|
|||||||
n ls Output downloaded versions
|
n ls Output downloaded versions
|
||||||
n ls-remote [version] Output matching versions available for download
|
n ls-remote [version] Output matching versions available for download
|
||||||
n uninstall Remove the installed Node.js
|
n uninstall Remove the installed Node.js
|
||||||
|
n download <version> Download Node.js <version> into cache
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
@ -794,6 +795,8 @@ install() {
|
|||||||
if [[ ! -e "$dir/n.lock" ]] ; then
|
if [[ ! -e "$dir/n.lock" ]] ; then
|
||||||
if [[ "$DOWNLOAD" == "false" ]] ; then
|
if [[ "$DOWNLOAD" == "false" ]] ; then
|
||||||
activate "${g_mirror_folder_name}/${version}"
|
activate "${g_mirror_folder_name}/${version}"
|
||||||
|
else
|
||||||
|
log downloaded "${g_mirror_folder_name}/${version} already in cache"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@ -802,7 +805,11 @@ install() {
|
|||||||
abort "version unavailable offline"
|
abort "version unavailable offline"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log installing "${g_mirror_folder_name}-v$version"
|
if [[ "$DOWNLOAD" == "false" ]]; then
|
||||||
|
log installing "${g_mirror_folder_name}-v$version"
|
||||||
|
else
|
||||||
|
log download "${g_mirror_folder_name}-v$version"
|
||||||
|
fi
|
||||||
|
|
||||||
local url="$(tarball_url "$version")"
|
local url="$(tarball_url "$version")"
|
||||||
is_ok "${url}" || abort "download preflight failed for '$version' ($(display_masked_url "${url}"))"
|
is_ok "${url}" || abort "download preflight failed for '$version' ($(display_masked_url "${url}"))"
|
||||||
@ -1733,6 +1740,7 @@ else
|
|||||||
lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
|
lsr|ls-remote|list-remote) shift; display_remote_versions "$1"; exit ;;
|
||||||
uninstall) uninstall_installed; exit ;;
|
uninstall) uninstall_installed; exit ;;
|
||||||
i|install) shift; install "$1"; exit ;;
|
i|install) shift; install "$1"; exit ;;
|
||||||
|
download) shift; DOWNLOAD="true"; install "$1"; exit ;;
|
||||||
N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
|
N_TEST_DISPLAY_LATEST_RESOLVED_VERSION) shift; get_latest_resolved_version "$1" > /dev/null || exit 2; echo "${g_target_node}"; exit ;;
|
||||||
*) install "$1"; exit ;;
|
*) install "$1"; exit ;;
|
||||||
esac
|
esac
|
||||||
|
@ -17,9 +17,22 @@ function teardown() {
|
|||||||
|
|
||||||
|
|
||||||
@test "n --download 4.9.1" {
|
@test "n --download 4.9.1" {
|
||||||
|
# deprecated use of --download, replaced by download command
|
||||||
n --download 4.9.1
|
n --download 4.9.1
|
||||||
[ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
|
[ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
|
||||||
# Remember, we installed a dummy node so do have a bin/node
|
[ ! -f "${N_PREFIX}/bin/node" ]
|
||||||
|
[ ! -f "${N_PREFIX}/bin/npm" ]
|
||||||
|
[ ! -d "${N_PREFIX}/include" ]
|
||||||
|
[ ! -d "${N_PREFIX}/lib" ]
|
||||||
|
[ ! -d "${N_PREFIX}/shared" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "n download 4.9.1" {
|
||||||
|
# not an option, but keep with --download so stays in sync
|
||||||
|
n download 4.9.1
|
||||||
|
[ -d "${N_PREFIX}/n/versions/node/4.9.1" ]
|
||||||
|
[ ! -f "${N_PREFIX}/bin/node" ]
|
||||||
[ ! -f "${N_PREFIX}/bin/npm" ]
|
[ ! -f "${N_PREFIX}/bin/npm" ]
|
||||||
[ ! -d "${N_PREFIX}/include" ]
|
[ ! -d "${N_PREFIX}/include" ]
|
||||||
[ ! -d "${N_PREFIX}/lib" ]
|
[ ! -d "${N_PREFIX}/lib" ]
|
||||||
@ -35,6 +48,14 @@ function teardown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "n --cleanup 4.9.1" {
|
||||||
|
n install --cleanup 4.9.1
|
||||||
|
output="$(node --version)"
|
||||||
|
assert_equal "${output}" "v4.9.1"
|
||||||
|
[ ! -d "${N_PREFIX}/n/versions/node/4.9.1" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# mostly --preserve, but also variations with i/install and lts/numeric
|
# mostly --preserve, but also variations with i/install and lts/numeric
|
||||||
@test "--preserve variations # (4 installs)" {
|
@test "--preserve variations # (4 installs)" {
|
||||||
local ARGON_VERSION="v4.9.1"
|
local ARGON_VERSION="v4.9.1"
|
||||||
|
@ -8,7 +8,7 @@ function setup_file() {
|
|||||||
unset_n_env
|
unset_n_env
|
||||||
setup_tmp_prefix
|
setup_tmp_prefix
|
||||||
# Note, NOT latest version of 16.
|
# Note, NOT latest version of 16.
|
||||||
n --download 16.19.0
|
n download 16.19.0
|
||||||
export N_NODE_MIRROR="https://no.internet.available"
|
export N_NODE_MIRROR="https://no.internet.available"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ function setup_file() {
|
|||||||
# fixed directory so can reuse the two installs
|
# fixed directory so can reuse the two installs
|
||||||
tmpdir="${TMPDIR:-/tmp}"
|
tmpdir="${TMPDIR:-/tmp}"
|
||||||
export N_PREFIX="${tmpdir}/n/test/run-which"
|
export N_PREFIX="${tmpdir}/n/test/run-which"
|
||||||
n --download 4.9.1
|
n download 4.9.1
|
||||||
n --download lts
|
n download lts
|
||||||
# using "latest" for download tests with run and exec
|
# using "latest" for download tests with run and exec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user