add dir checker for plugin:make

This commit is contained in:
crazywhalecc
2023-02-20 23:59:24 +08:00
committed by Jerry
parent 980ec8e293
commit 12b5e6f4e3

View File

@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace ZM\Command\Plugin;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\Question;
use ZM\Bootstrap;
@@ -22,6 +20,9 @@ abstract class PluginCommand extends Command
Bootstrap\LoadPlugins::class,
];
/** @var null|string 动态插件和 Phar 插件的加载目录 */
protected ?string $plugin_dir = null;
/**
* 插件名称合规验证器
*/
@@ -49,6 +50,9 @@ abstract class PluginCommand extends Command
if (PluginManager::isPluginExists($answer)) {
throw new \RuntimeException('名称为 ' . $answer . ' 的插件已存在,请换个名字');
}
if (is_dir(zm_dir($this->plugin_dir . '/' . $exp[1]))) {
throw new \RuntimeException('本插件名称的插件开发目录已经有相同名称,请先将同名插件的目录名修改,或修改本插件名称');
}
return $answer;
}
@@ -127,9 +131,4 @@ abstract class PluginCommand extends Command
default => '未知模式'
};
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
return parent::execute($input, $output);
}
}