Skip to content

Commit

Permalink
allow sed handing between linux and macos and bail if it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed Sep 22, 2023
1 parent 04eb10e commit 1b10c14
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions private/scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,19 @@ function update_composer() {
# Add a post-install hook to the composer.json.
echo "${yellow}Adding a post-install hook to composer.json.${normal}"
jq -r '.scripts += { "post-install-cmd": [ "@composer install --no-dev --prefer-dist --ignore-platform-reqs --working-dir=%sagedir%" ] }' composer.json > composer.new.json
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
sed -i '' "s,%sagedir%,$sagedir," composer.new.json
else
# Linux
sed -i "s,%sagedir%,$sagedir," composer.new.json
fi
sed -i '' "s,%sagedir%,$sagedir," composer.new.json
if [ $? -ne 0 ]; then
echo "${red}Failed to add post-install hook to composer.json. Exiting here.${normal}"
exit 1;
fi

rm composer.json
mv composer.new.json composer.json

Expand Down

0 comments on commit 1b10c14

Please sign in to comment.