mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
Copy system cert configs when installing new versions
This commit is contained in:
parent
28bc2fd991
commit
f6f5b20a8f
@ -16,6 +16,7 @@
|
||||
- [Long-term support](#long-term-support)
|
||||
- [Migrating global packages while installing](#migrating-global-packages-while-installing)
|
||||
- [Default global packages from file while installing](#default-global-packages-from-file-while-installing)
|
||||
- [Copy system certificate preferences when installing](#copy-system-certificate-preferences-when-installing)
|
||||
- [io.js](#iojs)
|
||||
- [System version of node](#system-version-of-node)
|
||||
- [Listing versions](#listing-versions)
|
||||
@ -310,6 +311,10 @@ object-inspect@1.0.2
|
||||
stevemao/left-pad
|
||||
```
|
||||
|
||||
### Copy system certificate preferences when installing
|
||||
|
||||
If you have any of `ca`, `cafile`, or `cert` present in your npm config when installing a new version, those keys will be copied into the newly-installed version's global config file. If you don't want this behavior, pass the `--skip-system-certs` flag when installing a new version
|
||||
|
||||
### io.js
|
||||
|
||||
If you want to install [io.js](https://github.com/iojs/io.js/):
|
||||
|
25
nvm.sh
25
nvm.sh
@ -2368,6 +2368,7 @@ nvm() {
|
||||
nvm_echo ' --lts When installing, only select from LTS (long-term support) versions'
|
||||
nvm_echo ' --lts=<LTS name> When installing, only select from versions for a specific LTS line'
|
||||
nvm_echo ' --skip-default-packages When installing, skip the default-packages file if it exists'
|
||||
nvm_echo ' --skip-system-certs When installing, skip copying certificate configuration from system npm'
|
||||
nvm_echo ' --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version'
|
||||
nvm_echo ' --no-progress Disable the progress bar on any downloads'
|
||||
nvm_echo ' nvm uninstall <version> Uninstall a version'
|
||||
@ -2640,6 +2641,8 @@ nvm() {
|
||||
local REINSTALL_PACKAGES_FROM
|
||||
local SKIP_DEFAULT_PACKAGES
|
||||
local DEFAULT_PACKAGES
|
||||
local SKIP_CERTS
|
||||
local CERT_CONFIGS
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
case "$1" in
|
||||
@ -2662,6 +2665,9 @@ nvm() {
|
||||
--skip-default-packages)
|
||||
SKIP_DEFAULT_PACKAGES=true
|
||||
;;
|
||||
--skip-system-certs)
|
||||
SKIP_CERTS=true
|
||||
;;
|
||||
*)
|
||||
ADDITIONAL_PARAMETERS="${ADDITIONAL_PARAMETERS} $1"
|
||||
;;
|
||||
@ -2677,6 +2683,10 @@ nvm() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${SKIP_CERTS-}" ]; then
|
||||
CERT_CONFIGS="$(nvm exec system npm config ls | sed -n 's/^\(ca\|cafile\|cert\)[ \t]*=[ \t]*\(.*\)$/\1 \2/p')"
|
||||
fi
|
||||
|
||||
if [ -n "${PROVIDED_REINSTALL_PACKAGES_FROM-}" ] && [ "$(nvm_ensure_version_prefix "${PROVIDED_REINSTALL_PACKAGES_FROM}")" = "${VERSION}" ]; then
|
||||
nvm_err "You can't reinstall global packages from the same version of node you're installing."
|
||||
return 4
|
||||
@ -2704,6 +2714,9 @@ nvm() {
|
||||
if [ -n "${REINSTALL_PACKAGES_FROM-}" ] && [ "_${REINSTALL_PACKAGES_FROM}" != "_N/A" ]; then
|
||||
nvm reinstall-packages "${REINSTALL_PACKAGES_FROM}"
|
||||
fi
|
||||
if [ -n "${CERT_CONFIGS}" ]; then
|
||||
nvm_copy_cert_configs "${CERT_CONFIGS}"
|
||||
fi
|
||||
fi
|
||||
if [ -n "${LTS-}" ]; then
|
||||
LTS="$(echo "${LTS}" | tr '[:upper:]' '[:lower:]')"
|
||||
@ -2782,6 +2795,9 @@ nvm() {
|
||||
nvm reinstall-packages "${REINSTALL_PACKAGES_FROM}"
|
||||
EXIT_CODE=$?
|
||||
fi
|
||||
if [ -n "${CERT_CONFIGS}" ]; then
|
||||
nvm_copy_cert_configs "${CERT_CONFIGS}"
|
||||
fi
|
||||
else
|
||||
EXIT_CODE=$?
|
||||
fi
|
||||
@ -3530,6 +3546,7 @@ nvm() {
|
||||
nvm_sanitize_path nvm_has_colors nvm_process_parameters \
|
||||
node_version_has_solaris_binary iojs_version_has_solaris_binary \
|
||||
nvm_curl_libz_support nvm_command_info nvm_is_zsh nvm_stdout_is_terminal \
|
||||
nvm_copy_cert_configs \
|
||||
>/dev/null 2>&1
|
||||
unset NVM_RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR \
|
||||
NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS \
|
||||
@ -3587,6 +3604,14 @@ nvm_install_default_packages() {
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_copy_cert_configs() {
|
||||
nvm_echo "Copying certificate information from system npm (if present)..."
|
||||
if ! nvm_echo "$1" | command xargs -L1 npm config set -g; then
|
||||
nvm_err "Failed to copy certificate configuration from system npm."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
nvm_supports_source_options() {
|
||||
# shellcheck disable=SC1091,SC2240
|
||||
[ "_$( . /dev/stdin yes 2> /dev/null <<'EOF'
|
||||
|
Loading…
Reference in New Issue
Block a user