fix command loader relative path

This commit is contained in:
sunxyw
2022-12-21 00:28:02 +08:00
parent 61ece52edc
commit 8901c31631
2 changed files with 17 additions and 9 deletions

View File

@@ -9,7 +9,6 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\OutputInterface;
use ZM\Exception\InitException;
use ZM\Utils\ZMUtil;
#[AsCommand(name: 'init', description: '初始化框架运行的基础文件')]
class InitCommand extends Command
@@ -46,7 +45,9 @@ class InitCommand extends Command
'Custom\\' => 'src/Custom',
],
'files' => [
'src/Custom/global_function.php',
'src/Globals/global_functions.php',
'src/Globals/global_defines_app.php',
'src/Globals/global_class_alias.php',
],
];
@@ -185,12 +186,7 @@ class InitCommand extends Command
private function getVendorPath(string $file): string
{
try {
$package_name = ZMUtil::getComposerMetadata()['name'];
} catch (\JsonException) {
throw new InitException('无法读取框架包的 composer.json', '请检查框架包完整性,或者重新安装框架包');
}
return $this->base_path . '/vendor/' . $package_name . $file;
return FRAMEWORK_ROOT_DIR . $file;
}
private function extractFiles(array $files, OutputInterface $output): void