Extracting composer_run(..) function

This commit is contained in:
Pavel Shevaev 2023-10-24 21:33:00 +03:00
parent c79c39e2bb
commit 23174277ac
1 changed files with 34 additions and 29 deletions

View File

@ -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']);
}