-
Hahn Axel (hahn) authoredHahn Axel (hahn) authored
inc_functions.php 3.42 KiB
<?php
// ----------------------------------------------------------------------
// SHARED FUNCTIONS FOR INSTALLER AND BUILDER
// ----------------------------------------------------------------------
$aCol=[
"reset" => "\e[0m",
"red" => "\e[31m",
"green" => "\e[32m",
"yellow" => "\e[33m",
"blue" => "\e[34m",
"magenta" => "\e[35m",
"cyan" => "\e[36m",
"light_gray" => "\e[37m",
"dark_gray" => "\e[90m",
"light_red" => "\e[91m",
"light_green" => "\e[92m",
"light_yellow" => "\e[93m",
"light_blue" => "\e[94m",
"light_magenta" => "\e[95m",
];
function _h1($s): void
{
global $aCol;
echo "\n$aCol[magenta]>>>>>>>>>> $s$aCol[reset]\n";
/*
echo "\n __".str_repeat("_", strlen($s))."\n";
echo "__/ ".str_repeat(" ", strlen($s))." \___".str_repeat("_", 70-strlen($s))."\n";
echo " $s\n";
echo str_repeat(".", 79)."\n\n";
*/
}
function _abort($sMessage, $iExitcode = 1): never
{
global $aCol;
echo "❌ $aCol[red]$sMessage.$aCol[reset]\n";
exit($iExitcode);
}
function _ok(string $sMessage=""): void
{
echo "✅ OK $sMessage\n";
}
function _skip(string $sMessage=""): void
{
echo "🔹 SKIP: $sMessage\n";
}
function _chdir($sDir): void
{
global $aCol;
if (!is_dir($sDir)) {
_abort("Directory '$sDir' not found.");
}
chdir($sDir);
echo "$aCol[cyan]dir # " . getcwd() . "$aCol[reset]\n";
}
/**
* Execute shell command and abort if it fails
* @param mixed $cmd
* @return void
*/
function _exec($cmd): void
{
global $aCol;
echo "$aCol[blue]cmd > $cmd$aCol[reset]\n";
$iStart=microtime(true);