Skip to content

Commit

Permalink
add safegurads for COMPOSER_AUTH
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Oct 14, 2022
1 parent 24dcb5c commit 964e4ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Version 0.4.3 (unreleased)
==========================
Version 0.5.0
=============

* allow to pass in github authentication for composer via env var GITHUB_TOKEN
* allow to pass in authentication for composer via env vars GITHUB_TOKEN, $PACKAGIST_TOKEN

* moved `master` branch to `main`

Expand Down
9 changes: 6 additions & 3 deletions bin/setup/composer-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -e

# Avoid spending time on composer if install will later fail
if [ ! -d "vendor" -a -L "vendor" ]; then
printf "\n\e[31mERROR:\e[0m vendor folder is not a symlink\n\n"
printf "\n\e[31mERROR:\e[0m vendor folder is not a symlink\n\n" >&2
exit 1
fi

Expand All @@ -26,7 +26,10 @@ if [ -n "$GITHUB_TOKEN" ]; then
composer_auth+=( '"github-oauth": {"github.com": "'"$GITHUB_TOKEN"'"}' )
fi
if ((${#composer_auth[@]})); then
# @todo check if COMPOSER_AUTH had been set already, to avoid overwriting it!
if [ -n "$COMPOSER_AUTH" ]; then
printf "\n\e[31mERROR:\e[0m COMPOSER_AUTH env var is set as well as PACKAGIST_TOKEN or GITHUB_TOKEN\n\n" >&2
exit 1
fi
export COMPOSER_AUTH="{$(IFS=$','; echo "${composer_auth[*]}")}"
fi

Expand All @@ -40,7 +43,7 @@ if [ -n "${EZ_COMPOSER_LOCK}" ]; then
echo "Installing packages via Composer using existing lock file ${EZ_COMPOSER_LOCK}..."

if [ ! -f "${EZ_COMPOSER_LOCK}" ]; then
printf "\n\e[31mERROR:\e[0m lock file can not be found\n\n"
printf "\n\e[31mERROR:\e[0m lock file can not be found\n\n" >&2
exit 1
fi

Expand Down

0 comments on commit 964e4ed

Please sign in to comment.