diff --git a/README.md b/README.md index bb158b4..23fb37a 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Setting the environment variable `GRUNT_INSTALL_NO_COLOR` will ```bash ⇒ grunt-install --help -grunt-install 0.0.0 +grunt-install 0.0.1 Usage: grunt-install [install_options] diff --git a/grunt-install.sh b/grunt-install.sh index 0d02e9a..7e4ae49 100755 --- a/grunt-install.sh +++ b/grunt-install.sh @@ -7,7 +7,7 @@ # Version Number -GRUNT_INSTALL_VERSION="0.0.0" +GRUNT_INSTALL_VERSION="0.0.1" # Template Directory @@ -23,10 +23,15 @@ GRUNT_COLOR_WHITE="\033[1;37m" # Script Variables +GRUNT_ME=$0 # useful for invoking this same script from within it GRUNT_INSTALL_FORCE=false GRUNT_INSTALL_SILENT=false +# Test-specific variables +[ ${GRUNT_INSTALL_UNIT_TEST} ] && GRUNT_ME="$BATS_TEST_DIRNAME/../grunt-install.sh" + + # installs from Github # # ${1} github shorthand e.g. GochoMugo/grunt-install @@ -121,15 +126,21 @@ grunt_install() { # updates grunt templates grunt_update_templates() { + local update_success=0 for template in ${GRUNT_TEMPLATE_DIRECTORY}/*/ ; do if [ -r ${template}/.grunt-install.config ] ; then template_name=$(basename ${template}) source ${template}/.grunt-install.config - ./grunt-install.sh ${GRUNT_TEMPLATE_UPDATE} ${template_name} --force --silent \ - && grunt_log "updated: ${template_name}" 1 \ - || grunt_log "failed to update: ${template_name}" 2 + ${GRUNT_ME} ${GRUNT_TEMPLATE_UPDATE} ${template_name} --force --silent + if [ $? -eq 0 ] ; then + grunt_log "updated: ${template_name}" 1 + else + grunt_log "failed to update: ${template_name}" 2 + update_success=1 + fi fi done + return ${update_success} } diff --git a/package.json b/package.json index d78e71a..9e909df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-install", - "version": "0.0.0", + "version": "0.0.1", "description": "Simple Bash script for Grunt template installation", "directories": { "test": "test" diff --git a/test/test.grunt-install.sh b/test/test.grunt-install.sh index 2eb77ee..fb2f627 100644 --- a/test/test.grunt-install.sh +++ b/test/test.grunt-install.sh @@ -63,3 +63,15 @@ make_fake_template() { grunt_log "Wont show up on console" 0 > _TEST_grunt_log_file [ $(grep -c -E "*" _TEST_grunt_log_file) -eq 0 ] } + + +# refer to issue #1 (https://github.com/GochoMugo/grunt-install/issues/1) +@test "grunt_update_templates: updates templates regardless of working directory" { + mkdir _TEST_grunt_update_cwd + cd _TEST_grunt_update_cwd + grunt_update_templates > log + [ $(grep -c -E "failed to update" log) -eq 0 ] + exit_code=$? + cd - + return $? +}