Skip to content
Myr

Revert "install: adding some debugging output"

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This reverts commit c8efe3d28ab862441f7f40e2683b1a91688aabc4. Conflicts: install.sh

authored by Jordan Harband · committed by Jordan Harband · parent 4768973 · Browse files · 3 files+10 added−70 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−70 removed

  • tests:+6 added−39 removed
  • other:+4 added−31 removed

3 files+10 added−70 removed

modified:test/install_script/nvm_check_global_modules+6 added-39 removed
1#!/bin/sh2puts() (IFS=" "; printf %s\\n "$*" ;)23cleanup () {4 rm -rf "$npm_config_prefix/lib" >/dev/null 2>&15 unset npm_config_prefix
3 unmodified lines
910 unset -f setup cleanup die11 unset message ORIGINAL_PATH12}13die () { echo $@ ; cleanup ; exit 1; }1415die () { puts "!! $@" ; cleanup ; exit 1; }1615NVM_ENV=testing . ../../install.sh1617setup () {18 ORIGINAL_PATH="$PATH"
2 unmodified lines
21 export npm_config_prefix22 mkdir -p "$npm_config_prefix/lib"23}242526setup272928npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'29message=$(nvm_check_global_modules)32[ ! -z "$message" ] || {33 puts '-- `npm --version`: '"$(npm --version)"34 puts '-- `npm list -g`:'35 npm list -g --depth=036 puts '-- Printed message:'37 puts "'''$message'''"30[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed"3139 die "nvm_check_global_modules should have printed a notice when npm had global modules installed" ;}404132npm uninstall -g nop >/dev/null33message=$(nvm_check_global_modules)44[ -z "$message" ] || {45 puts '-- `npm --version`: '"$(npm --version)"46 puts '-- `npm list -g`:'47 npm list -g --depth=048 puts '-- Printed message:'49 puts "'''$message'''"34[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed"3551 die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed" ;}525336# Faking an installation of npm37mkdir -p "$npm_config_prefix/lib/node_modules/npm"38cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json"39{ "name": "npm", "version": "0.0.1fake" }40JSON4142message=$(nvm_check_global_modules)61[ -z "$message" ] || {62 puts '-- `which npm`: ' "$(which npm)"63 puts '-- `npm --version`: ' "$(npm --version)"64 puts '-- `npm list -g`:'65 npm list -g --depth=066 puts '-- Printed message:'67 puts "'''$message'''"43[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module"4469 die "nvm_check_global_modules should not have printed a notice when npm had only itself installed as a global module" ;}707145# Faking the absence of npm46PATH=".:$PATH"47touch npm48chmod +x npm4950message=$(nvm_check_global_modules)78[ -z "$message" ] || {79 puts '-- `which npm`: ' "$(which npm)"80 puts '-- `npm --version`: ' "$(npm --version)"81 puts '-- Printed message:'82 puts "'''$message'''"51[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable"5284 die "nvm_check_global_modules should not have printed a notice when npm was unavailable" ;}538654cleanup
modified:.travis.yml+1 added-1 removed
modified:install.sh+3 added-30 removed
1#!/bin/bash23set -e44puts() (IFS=" "; printf %s\\n "$*" ;)5error() (IFS=" "; printf %s\\n "$*" >&2 ;)6debug() (IFS=" "; printf %s\\n ".. $*" >&2 ;)78if [ "$DEBUG" = 'nvm:*' ] || [ "$DEBUG" = 'nvm:install' ]; then9 NVM_DEBUG=010 debug 'Script debugging enabled (in: `install.sh`).'11fi12135nvm_has() {6 type "$1" > /dev/null 2>&17}8
32 unmodified lines
41}4243nvm_download() {44 if nvm_has "curl"; then54 [ "$NVM_DEBUG" = 0 ] && set +x45 curl $*56 [ "$NVM_DEBUG" = 0 ] && set -x46 elif nvm_has "wget"; then47 # Emulate curl with wget48 ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \49 -e 's/-L //' \50 -e 's/-I /--server-response /' \51 -e 's/-s /-q /' \52 -e 's/-o /-O /' \53 -e 's/-C - /-c /')65 [ "$NVM_DEBUG" = 0 ] && set +x54 wget $ARGS67 [ "$NVM_DEBUG" = 0 ] && set +x55 fi56}5758install_nvm_from_git() {
6 unmodified lines
65 else66 # Cloning to $NVM_DIR67 echo "=> Downloading nvm from git to '$NVM_DIR'"68 printf "\r=> "82 [ "$NVM_DEBUG" = 0 ] && set +x69 mkdir -p "$NVM_DIR"70 command git clone "$(nvm_source git)" "$NVM_DIR"85 [ "$NVM_DEBUG" = 0 ] && set -x71 fi87 88 [ "$NVM_DEBUG" = 0 ] && set +x89 cd "$NVM_DIR" || return $?90 command git checkout --quiet $(nvm_latest_version) || return $?91 command git branch --quiet -D master >/dev/null 2>&1 || return $?92 [ "$NVM_DEBUG" = 0 ] && set +x93 72 cd "$NVM_DIR" && command git checkout --quiet $(nvm_latest_version) && command git branch --quiet -D master >/dev/null 2>&173 return74}7576install_nvm_as_script() {
52 unmodified lines
129130 local NPM_VERSION131 NPM_VERSION="$(npm --version)"132 NPM_VERSION="${NPM_VERSION:--1}"154 [ "$NVM_DEBUG" = 0 ] && debug "NPM detected (at version ${NPM_VERSION}.)"133 [ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0134135 local NPM_GLOBAL_MODULES136 NPM_GLOBAL_MODULES="$(
7 unmodified lines
144 printf %s\\n "$NPM_GLOBAL_MODULES" |145 sed -ne '1!p' | # Remove the first line146 wc -l | tr -d ' ' # Count entries147 )"170 [ "$NVM_DEBUG" = 0 ] && {171 debug "(${MODULE_COUNT}) global modules detected:"172 error "$NPM_GLOBAL_MODULES" ;}148149 if [ $MODULE_COUNT -ne 0 ]; then150 cat <<-'END_MESSAGE'151 => You currently have modules installed globally with `npm`. These will no
74 unmodified lines
226# Unsets the various functions defined227# during the execution of the install script228#229nvm_reset() {255 unset -f puts error debug \256 nvm_reset nvm_has nvm_latest_version \230 unset -f nvm_reset nvm_has nvm_latest_version \231 nvm_source nvm_download install_nvm_as_script install_nvm_from_git \232 nvm_detect_profile nvm_check_global_modules nvm_do_install 259 unset NPM_DEBUG233}234235[ "_$NVM_ENV" = "_testing" ] || nvm_do_install