Skip to content

Commit

Permalink
fix(update): fix issue when SHA cannot be found
Browse files Browse the repository at this point in the history
* add support for force updating prompt

* ignore update-prompt check when the SHA cannot be retrieved from github

* resolve an issue where a variable in add-var may be placed on the current line in the event that the file does not end in a newline (POSIX)

* delete-prefix on nvm-use

* remove backups when updating prompt
  • Loading branch information
Deavon M. McCaffery committed Oct 31, 2017
1 parent 6da2914 commit 1e014a8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/scripts/add-var.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add-var() {
local varpath="$AM_PROMPT/user/variables.sh"

echo Adding varable: $v
echo $v >> "$varpath"
echo "\n$v" >> "$varpath"
source "$varpath"
}

Expand Down
14 changes: 13 additions & 1 deletion src/scripts/git-extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ git-sha() {
local SHA_URI=https://api.github.com/repos/$ORG_NAME/$REPO_NAME/commits/$BRANCH_NAME
local SHA=$(curl $CURL_OPT $SHA_URI | grep sha | head -n 1 | sed 's#.*\:.*"\(.*\).*",#\1#')

echo $SHA
if [ ! -z "${AM_PROMPT_DEBUG:-}" ]; then
echo "curl $CURL_OPT $SHA_URI"
fi

if [ ! -z "${SHA:-}" ]; then
echo $SHA
return 0
fi

echo "ERROR RETRIEVING GIT SHA FOR $SHA_URI"
echo "$(curl $CURL_OPT $SHA_URI)"

return 1
}

git-token() {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/set-nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ __prompt-set-nvm()
source "$nvm_path/nvm.sh"
fi

nvm use --lts
nvm use --lts --delete-prefix
eval "$(npm completion)"
}
17 changes: 14 additions & 3 deletions src/scripts/update-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ update-prompt() {
local SHA=$(git-sha)
local SHA_PATH=$HOME/.am/prompt/.sha

if [ -f $SHA_PATH ]; then
if [ "${1:-}" = "--force" ]; then
rm -rf $SHA_PATH 1>/dev/null 2>&1
fi

remove-backup

if [ -f "${SHA_PATH:-}" ]; then
CURRENT_SHA=$(cat $SHA_PATH)

if [ $SHA = $CURRENT_SHA ]; then
echo "prompt: latest version already installed: $SHA"
if [ -z "${SHA:-}" ]; then
echo "prompt: SHA cannot be retrieved, which could be related to rate limiting."
return 1
fi

if [ "${SHA:-}" = "${CURRENT_SHA:-}" ]; then
echo "prompt: latest version already installed: $SHA"
return 0
fi
fi

local CHANGELOG_URI="https://github.com/automotivemastermind/prompt/blob/master/CHANGELOG.md"
Expand Down
2 changes: 1 addition & 1 deletion uname/install-Darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ __prompt-install-darwin() {
source "$nvm_path/nvm.sh"

nvm install --lts 1>/dev/null 2>&1
nvm use --lts 1>/dev/null 2>&1
nvm use --lts --delete-prefix 1>/dev/null 2>&1
fi

__prompt-success 'setting git credential helper to use the macOS keychain'
Expand Down
2 changes: 1 addition & 1 deletion uname/install-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ sudo apt-get autoremove -y 1>/dev/null

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
nvm install --lts 1>/dev/null
nvm use --lts 1>/dev/null
nvm use --lts --delete-prefix 1>/dev/null
2 changes: 1 addition & 1 deletion uname/install-fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ done

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
nvm install --lts 1>/dev/null
nvm use --lts 1>/dev/null
nvm use --lts --delete-prefix 1>/dev/null

wget --no-check-certificate -q https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh && sudo bash gitflow-installer.sh install stable; rm gitflow-installer.sh
2 changes: 1 addition & 1 deletion uname/install-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ sudo apt-get autoremove -y 1>/dev/null

curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
nvm install --lts 1>/dev/null
nvm use --lts 1>/dev/null
nvm use --lts --delete-prefix 1>/dev/null

0 comments on commit 1e014a8

Please sign in to comment.