build: Fix cleanup of the backup composer lock file

The trap function was registered as the last bash instruction and as a
result was not executed if anything failed before, e.g. the composer
update command or building the PHAR itself.

In the event the build PHAR script fails, the temporary backup
composer.lock file may be created and not removed.
This commit is contained in:
Théo FIDRY
2023-03-14 23:43:28 +01:00
parent dc441bb16c
commit 3af121d073
2 changed files with 3 additions and 2 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@ dist/
tests/phpunit.xml
vendor/
/composer.lock
/composer.lock.back
phpunit.xml
/.phpunit.result.cache
/phpcs.xml

View File

@@ -9,11 +9,11 @@ function restorePlatform {
mv -f composer.lock.back composer.lock || true
}
trap restorePlatform exit
# lock PHP to minimum allowed version
composer config platform.php 7.2.0
cp composer.lock composer.lock.back || true
composer update
php box.phar compile -vv
trap restorePlatform exit