mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
add exception handler for command build:libs
This commit is contained in:
parent
fd835deb8d
commit
e62cefa9e5
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace SPC\command;
|
namespace SPC\command;
|
||||||
|
|
||||||
use SPC\builder\BuilderProvider;
|
use SPC\builder\BuilderProvider;
|
||||||
|
use SPC\exception\ExceptionHandler;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
@ -30,6 +31,7 @@ class BuildLibsCommand extends BuildCommand
|
|||||||
if ($input->getOption('all')) {
|
if ($input->getOption('all')) {
|
||||||
$input->setArgument('libraries', '');
|
$input->setArgument('libraries', '');
|
||||||
}
|
}
|
||||||
|
parent::initialize($input, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,15 +57,25 @@ class BuildLibsCommand extends BuildCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建对象
|
try {
|
||||||
$builder = BuilderProvider::makeBuilderByInput($input);
|
// 构建对象
|
||||||
// 只编译 library 的情况下,标记
|
$builder = BuilderProvider::makeBuilderByInput($input);
|
||||||
$builder->setLibsOnly();
|
// 只编译 library 的情况下,标记
|
||||||
// 编译和检查库完整
|
$builder->setLibsOnly();
|
||||||
$builder->buildLibs($libraries);
|
// 编译和检查库完整
|
||||||
|
$builder->buildLibs($libraries);
|
||||||
|
|
||||||
$time = round(microtime(true) - START_TIME, 3);
|
$time = round(microtime(true) - START_TIME, 3);
|
||||||
logger()->info('Build libs complete, used ' . $time . ' s !');
|
logger()->info('Build libs complete, used ' . $time . ' s !');
|
||||||
return 0;
|
return 0;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
if ($input->getOption('debug')) {
|
||||||
|
ExceptionHandler::getInstance()->handle($e);
|
||||||
|
} else {
|
||||||
|
logger()->critical('Build failed with ' . get_class($e) . ': ' . $e->getMessage());
|
||||||
|
logger()->critical('Please check with --debug option to see more details.');
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user