Skip to content

Commit

Permalink
accommodate new GH token format
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbentrup committed Jun 16, 2021
1 parent 133191e commit de9d641
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,13 @@ get_github_token_from_composer_auth() {
local token
[[ "$COMPOSER_AUTH" ]] && {
token="$(echo "$COMPOSER_AUTH" | perl -ne '/github.com".*?"([^"]*)"/ and print "$1"')"
[[ "$token" =~ [a-zA-Z0-9]{20,} ]] && echo "$token" && return
[[ "$token" ]] || token="$(echo "$COMPOSER_AUTH" | perl -ne '/(ghp_[^"]*)/ and print "$1"')"
[[ "$token" =~ [a-zA-Z0-9_]{20,} ]] && echo "$token" && return
}
[[ -f "$HOME/.composer/auth.json" ]] && {
token="$(perl -ne '/github.com".*?"([^"]*)"/ and print "$1"' "$HOME/.composer/auth.json")"
[[ "$token" =~ [a-zA-Z0-9]{20,} ]] && echo "$token" && return
[[ "$token" ]] || token="$(perl -ne '/(ghp_[^"]*)/ and print "$1"' "$HOME/.composer/auth.json")"
[[ "$token" =~ [a-zA-Z0-9_]{20,} ]] && echo "$token" && return
}
return 1
}
Expand Down

0 comments on commit de9d641

Please sign in to comment.