diff --git a/.github/workflows/windows-npm.yml b/.github/workflows/windows-npm.yml index 90c5002..29fef33 100644 --- a/.github/workflows/windows-npm.yml +++ b/.github/workflows/windows-npm.yml @@ -87,6 +87,9 @@ jobs: wsl_matrix: name: 'WSL nvm install' + defaults: + run: + shell: wsl-bash {0} runs-on: windows-latest env: WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p @@ -99,19 +102,24 @@ jobs: - Ubuntu-18.04 npm-node-version: - '--lts' + - '14' + - '12' - '11' + - '10' + method: + - '' + - 'script' steps: - uses: Vampire/setup-wsl@v1 with: distribution: ${{ matrix.wsl-distrib }} - additional-packages: bash git curl ca-certificates + additional-packages: bash git curl ca-certificates wget - name: Retrieve nvm on WSL - shell: wsl-bash {0} run: | - if [ "${{ matrix.wsl-distrib }}" = "Ubuntu-18.04" ] && [ "${{ matrix.npm-node-version }}" = "--lts" ]; then + if [ -z "${{ matrix.method }}" ]; then curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash else - curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash + curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash fi . "$HOME/.nvm/nvm.sh" nvm install ${{ matrix.npm-node-version }} diff --git a/README.md b/README.md index 8891021..4f2b588 100644 --- a/README.md +++ b/README.md @@ -572,7 +572,7 @@ cdnvm() { nvm use default; fi - elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then + elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then declare nvm_version nvm_version=$(<"$nvm_path"/.nvmrc) @@ -913,6 +913,7 @@ Some issues you may encounter: $ NODE_OPTIONS="--max-old-space-size=4096" ./node_modules/.bin/your_node_package ``` - when using `nvm` to install some versions, the compilation fails +- after `nvm` successfully compiles some versions, `yarn` or `npm` may later fail to install packages with an `incorrect data check` error. One solution to this issue is to change the architecture of your shell from arm64 to x86. diff --git a/install.sh b/install.sh index af8fb6e..eb37d04 100755 --- a/install.sh +++ b/install.sh @@ -160,11 +160,11 @@ install_nvm_from_git() { exit 2 } if [ -n "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then - if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then - command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1 + if command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then + command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1 else nvm_echo >&2 "Your version of git is out of date. Please update it!" - command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1 + command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1 fi fi @@ -300,7 +300,7 @@ nvm_detect_profile() { nvm_check_global_modules() { local NPM_COMMAND NPM_COMMAND="$(command -v npm 2>/dev/null)" || return 0 - [ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%$NVM_DIR/*}" ] && return 0 + [ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%"$NVM_DIR"/*}" ] && return 0 local NPM_VERSION NPM_VERSION="$(npm --version)" @@ -360,7 +360,7 @@ nvm_do_install() { # Autodetect install method if nvm_has git; then install_nvm_from_git - elif nvm_has nvm_download; then + elif nvm_has curl || nvm_has wget; then install_nvm_as_script else nvm_echo >&2 'You need git, curl, or wget to install nvm' @@ -373,7 +373,7 @@ nvm_do_install() { fi install_nvm_from_git elif [ "${METHOD}" = 'script' ]; then - if ! nvm_has nvm_download; then + if ! nvm_has curl && ! nvm_has wget; then nvm_echo >&2 "You need curl or wget to install nvm" exit 1 fi diff --git a/nvm.sh b/nvm.sh index 72992c1..f65e991 100644 --- a/nvm.sh +++ b/nvm.sh @@ -634,7 +634,7 @@ nvm_remote_versions() { NVM_LS_REMOTE_EXIT_CODE=$? # split output into two NVM_LS_REMOTE_PRE_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT%%v4\.0\.0*}" - NVM_LS_REMOTE_POST_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT#$NVM_LS_REMOTE_PRE_MERGED_OUTPUT}" + NVM_LS_REMOTE_POST_MERGED_OUTPUT="${NVM_LS_REMOTE_OUTPUT#"$NVM_LS_REMOTE_PRE_MERGED_OUTPUT"}" fi local NVM_LS_REMOTE_IOJS_EXIT_CODE @@ -940,7 +940,7 @@ nvm_print_alias_path() { return 2 fi local ALIAS - ALIAS="${ALIAS_PATH##${NVM_ALIAS_DIR}\/}" + ALIAS="${ALIAS_PATH##"${NVM_ALIAS_DIR}"\/}" local DEST DEST="$(nvm_alias "${ALIAS}" 2>/dev/null)" ||: if [ -n "${DEST}" ]; then @@ -1186,7 +1186,7 @@ nvm_strip_iojs_prefix() { if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then nvm_echo else - nvm_echo "${1#${NVM_IOJS_PREFIX}-}" + nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" fi } @@ -2614,7 +2614,7 @@ nvm_node_version_has_solaris_binary() { # Succeeds if $VERSION represents a version (node, io.js or merged) that has a # Solaris binary, fails otherwise. nvm_has_solaris_binary() { - local VERSION=$1 + local VERSION="${1-}" if nvm_is_merged_node_version "${VERSION}"; then return 0 # All merged node versions have a Solaris binary elif nvm_is_iojs_version "${VERSION}"; then diff --git a/package.json b/package.json index c0630c6..dc3efd5 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "homepage": "https://github.com/nvm-sh/nvm", "devDependencies": { "dockerfile_lint": "^0.3.4", - "doctoc": "^2.0.1", + "doctoc": "^2.1.0", "eclint": "^2.8.1", "markdown-link-check": "^3.8.7", "replace": "^1.2.1",