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
Provenance
- Commit
f0d81e2- Tree
22084d3- Author
Jordan Harband <ljharb@gmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
4768973
3 files changed+10 added−70 removed
modified:test/install_script/nvm_check_global_modules+6 added-39 removed
1 #!/bin/sh2-puts() (IFS=" "; printf %s\\n "$*" ;)2 3 cleanup () {4 rm -rf "$npm_config_prefix/lib" >/dev/null 2>&15 unset npm_config_prefix3 unmodified lines9 10 unset -f setup cleanup die11 unset message ORIGINAL_PATH12 }13+die () { echo $@ ; cleanup ; exit 1; }14 15-die () { puts "!! $@" ; cleanup ; exit 1; }16-15 NVM_ENV=testing . ../../install.sh16 17 setup () {18 ORIGINAL_PATH="$PATH"2 unmodified lines21 export npm_config_prefix22 mkdir -p "$npm_config_prefix/lib"23 }24 25+26 setup27 29-28 npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'29 message=$(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"31 39- die "nvm_check_global_modules should have printed a notice when npm had global modules installed" ;}40-41-32 npm uninstall -g nop >/dev/null33 message=$(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"35 51- die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed" ;}52-53-36 # Faking an installation of npm37 mkdir -p "$npm_config_prefix/lib/node_modules/npm"38 cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json"39 { "name": "npm", "version": "0.0.1fake" }40 JSON41 42 message=$(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"44 69- die "nvm_check_global_modules should not have printed a notice when npm had only itself installed as a global module" ;}70-71-45 # Faking the absence of npm46 PATH=".:$PATH"47 touch npm48 chmod +x npm49 50 message=$(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"52 84- die "nvm_check_global_modules should not have printed a notice when npm was unavailable" ;}53 86-54 cleanupmodified:.travis.yml+1 added-1 removed
3 unmodified lines456788910111227 unmodified lines3 unmodified lines - (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*) - chmod +x /tmp/urchin/package/urchin - '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'script: - DEBUG='nvm:*' NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL - NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELLenv: - SHELL=sh TEST_SUITE=install_script - SHELL=dash TEST_SUITE=install_script - SHELL=bash TEST_SUITE=install_script27 unmodified linesmodified:install.sh+3 added-30 removed
1 #!/bin/bash2+3 set -e4 4-puts() (IFS=" "; printf %s\\n "$*" ;)5-error() (IFS=" "; printf %s\\n "$*" >&2 ;)6-debug() (IFS=" "; printf %s\\n ".. $*" >&2 ;)7-8-if [ "$DEBUG" = 'nvm:*' ] || [ "$DEBUG" = 'nvm:install' ]; then9- NVM_DEBUG=010- debug 'Script debugging enabled (in: `install.sh`).'11-fi12-13-5 nvm_has() {6 type "$1" > /dev/null 2>&17 }8 32 unmodified lines41 }42 43 nvm_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 }57 58 install_nvm_from_git() {6 unmodified lines65 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 }75 76 install_nvm_as_script() {52 unmodified lines129 130 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 0134 135 local NPM_GLOBAL_MODULES136 NPM_GLOBAL_MODULES="$(7 unmodified lines144 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" ;}148 149 if [ $MODULE_COUNT -ne 0 ]; then150 cat <<-'END_MESSAGE'151 => You currently have modules installed globally with `npm`. These will no74 unmodified lines226 # Unsets the various functions defined227 # during the execution of the install script228 #229 nvm_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 }234 235 [ "_$NVM_ENV" = "_testing" ] || nvm_do_install