Fix composer permissions on unix

This commit is contained in:
Shivam Mathur 2021-07-21 19:00:00 +05:30
parent 6a8a2abd3c
commit 36cb9fb0fc
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -7,9 +7,10 @@ export jit_versions="8.[0-9]"
export nightly_versions="8.[1-9]" export nightly_versions="8.[1-9]"
export xdebug3_versions="7.[2-4]|8.[0-9]" export xdebug3_versions="7.[2-4]|8.[0-9]"
export tool_path_dir="/usr/local/bin" export tool_path_dir="/usr/local/bin"
export composer_bin="$HOME/.composer/vendor/bin" export composer_home="$HOME/.composer"
export composer_json="$HOME/.composer/composer.json" export composer_bin="$composer_home/vendor/bin"
export composer_lock="$HOME/.composer/composer.lock" export composer_json="$composer_home/composer.json"
export composer_lock="$composer_home/composer.lock"
export latest="releases/latest/download" export latest="releases/latest/download"
export github="https://github.com/shivammathur" export github="https://github.com/shivammathur"
export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur" export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
@ -232,10 +233,14 @@ configure_composer() {
add_log "$cross" "composer" "Could not download composer" add_log "$cross" "composer" "Could not download composer"
exit 1 exit 1
fi fi
if ! [ -d "$composer_home" ]; then
sudo -u "$(id -un)" -g "$(id -gn)" mkdir -p -m=00755 "$composer_home"
else
sudo chown -R "$(id -un)":"$(id -gn)" "$composer_home"
fi
if ! [ -e "$composer_json" ]; then if ! [ -e "$composer_json" ]; then
sudo mkdir -p "$(dirname "$composer_json")"
echo '{}' | tee "$composer_json" >/dev/null echo '{}' | tee "$composer_json" >/dev/null
sudo chmod 644 "$composer_json" chmod 644 "$composer_json"
fi fi
composer -q config -g process-timeout 0 composer -q config -g process-timeout 0
echo "$composer_bin" >>"$GITHUB_PATH" echo "$composer_bin" >>"$GITHUB_PATH"