From 23174277ac9dce22d80b1da02fa1c12a657b9fd2 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Tue, 24 Oct 2023 21:33:00 +0300 Subject: [PATCH] Extracting composer_run(..) function --- composer.inc.php | 63 ++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/composer.inc.php b/composer.inc.php index 9259e6e..043d995 100644 --- a/composer.inc.php +++ b/composer.inc.php @@ -19,29 +19,8 @@ task('composer_reset', function() ensure_rm("$GAME_ROOT/composer/composer.last"); }); -task('composer', function($args) { - global $GAME_ROOT; - - $composer_dir = $GAME_ROOT . '/composer/'; - - $files = glob($composer_dir . '/composer-*.phar'); - $PHAR = basename($files[0]); - - $cmd = "cd $composer_dir && "; - if(PHP_OS_FAMILY === 'Darwin') - { - $cmd .= "DYLD_LIBRARY_PATH='" . getenv("DYLD_LIBRARY_PATH") . "' " . - "PHP_INI_SCAN_DIR='" . getenv("PHP_INI_SCAN_DIR") . "' "; - $cmd .= PHP_BINARY . " -c '". getenv("PHP_INI") . "' "; - $ext_dir = realpath(ini_get('extension_dir')); - $cmd .= " -d extension_dir='$ext_dir' "; - } - else - $cmd .= PHP_BINARY . ' '; - - $cmd .= "$PHAR " . implode(' ', $args); - - shell($cmd); +task('composer', function(array $args) { + composer_run($args); }); task('composer_vendor_push', function($args) { @@ -210,12 +189,38 @@ function composer_try_update_lock_entry($package, $rev, $new_tag) return $changed; } -//NOTE: COMPOSER_FORCE_UPDATE = true will make composer to update packages and -// a lock file -// COMPOSER_FORCE_UPDATE = false will make composer install dependencies -// listed in a lock file in case if it's present -function composer_update($COMPOSER_FORCE_UPDATE = false) +function composer_run(array $args) { global $GAME_ROOT; - include("$GAME_ROOT/composer/update.php"); + + $composer_dir = $GAME_ROOT . '/composer/'; + + $files = glob($composer_dir . '/composer-*.phar'); + $PHAR = basename($files[0]); + + $cmd = "cd $composer_dir && "; + if(PHP_OS_FAMILY === 'Darwin') + { + $cmd .= "DYLD_LIBRARY_PATH='" . getenv("DYLD_LIBRARY_PATH") . "' " . + "PHP_INI_SCAN_DIR='" . getenv("PHP_INI_SCAN_DIR") . "' "; + $cmd .= PHP_BINARY . " -c '". getenv("PHP_INI") . "' "; + $ext_dir = realpath(ini_get('extension_dir')); + $cmd .= " -d extension_dir='$ext_dir' "; + } + else + $cmd .= PHP_BINARY . ' '; + + $cmd .= "$PHAR " . implode(' ', $args); + + shell($cmd); } + +//NOTE: keeping this function for BC +function composer_update($update = false) +{ + if($update) + composer_run(['update --no-dev']); + else + composer_run(['install --no-dev']); +} +