diff options
author | Pol Dellaiera <pol.dellaiera@protonmail.com> | 2024-03-05 15:25:16 +0100 |
---|---|---|
committer | Pol Dellaiera <pol.dellaiera@protonmail.com> | 2024-03-05 22:00:46 +0100 |
commit | 5e9aea3fbab696fb2b5cd3305b78e41468f6215a (patch) | |
tree | 6e6ad1f44741469f5580cbd4623ae1050bac75b8 | |
parent | 36f38012b5115d6d61aaf8b1b39ddd511c75f498 (diff) |
build-support/php: move functions around (dry)
(cherry picked from commit bc627a6acad591f05e8b879a9388137859e10855)
-rw-r--r-- | pkgs/build-support/php/hooks/composer-install-hook.sh | 21 | ||||
-rw-r--r-- | pkgs/build-support/php/hooks/composer-repository-hook.sh | 21 | ||||
-rw-r--r-- | pkgs/build-support/php/hooks/php-script-utils.bash | 24 |
3 files changed, 26 insertions, 40 deletions
diff --git a/pkgs/build-support/php/hooks/composer-install-hook.sh b/pkgs/build-support/php/hooks/composer-install-hook.sh index 0ff6e8f6febf8..e865ae116be2b 100644 --- a/pkgs/build-support/php/hooks/composer-install-hook.sh +++ b/pkgs/build-support/php/hooks/composer-install-hook.sh @@ -91,26 +91,7 @@ composerInstallBuildHook() { composerInstallCheckHook() { echo "Executing composerInstallCheckHook" - if ! composer validate --strict --no-ansi --no-interaction --quiet; then - if [ ! -z "${composerStrictValidation-}" ]; then - echo - echo -e "\e[31mERROR: composer files validation failed\e[0m" - echo - echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m' - echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m' - echo - exit 1 - else - echo - echo -e "\e[33mWARNING: composer files validation failed\e[0m" - echo - echo -e '\e[33mThe validation of the composer.json and composer.lock failed.\e[0m' - echo -e '\e[33mMake sure that the file composer.lock is consistent with composer.json.\e[0m' - echo - echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' - echo - fi - fi + checkComposerValidate echo "Finished composerInstallCheckHook" } diff --git a/pkgs/build-support/php/hooks/composer-repository-hook.sh b/pkgs/build-support/php/hooks/composer-repository-hook.sh index ffec58e552931..762e762761cc4 100644 --- a/pkgs/build-support/php/hooks/composer-repository-hook.sh +++ b/pkgs/build-support/php/hooks/composer-repository-hook.sh @@ -71,26 +71,7 @@ composerRepositoryBuildHook() { composerRepositoryCheckHook() { echo "Executing composerRepositoryCheckHook" - if ! composer validate --strict --no-ansi --no-interaction --quiet; then - if [ ! -z "${composerStrictValidation-}" ]; then - echo - echo -e "\e[31mERROR: composer files validation failed\e[0m" - echo - echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m' - echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m' - echo - exit 1 - else - echo - echo -e "\e[33mWARNING: composer files validation failed\e[0m" - echo - echo -e '\e[33mThe validation of the composer.json and composer.lock failed.\e[0m' - echo -e '\e[33mMake sure that the file composer.lock is consistent with composer.json.\e[0m' - echo - echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' - echo - fi - fi + checkComposerValidate echo "Finished composerRepositoryCheckHook" } diff --git a/pkgs/build-support/php/hooks/php-script-utils.bash b/pkgs/build-support/php/hooks/php-script-utils.bash index 163d9306f5f4a..60afacbed0af1 100644 --- a/pkgs/build-support/php/hooks/php-script-utils.bash +++ b/pkgs/build-support/php/hooks/php-script-utils.bash @@ -1,4 +1,5 @@ declare version +declare composerStrictValidation setComposeRootVersion() { set +e # Disable exit on error @@ -10,3 +11,26 @@ setComposeRootVersion() { set -e } + +checkComposerValidate() { + if ! composer validate --strict --no-ansi --no-interaction; then + if [ "1" == "${composerStrictValidation-}" ]; then + echo + echo -e "\e[31mERROR: composer files validation failed\e[0m" + echo + echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m' + echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m' + echo + exit 1 + else + echo + echo -e "\e[33mWARNING: composer files validation failed\e[0m" + echo + echo -e '\e[33mThe validation of the composer.json and composer.lock failed.\e[0m' + echo -e '\e[33mMake sure that the file composer.lock is consistent with composer.json.\e[0m' + echo + echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' + echo + fi + fi +} |