mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 16:15:34 +08:00
add dir checker for plugin:make
This commit is contained in:
@@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace ZM\Command\Plugin;
|
namespace ZM\Command\Plugin;
|
||||||
|
|
||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
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\ChoiceQuestion;
|
||||||
use Symfony\Component\Console\Question\Question;
|
use Symfony\Component\Console\Question\Question;
|
||||||
use ZM\Bootstrap;
|
use ZM\Bootstrap;
|
||||||
@@ -22,6 +20,9 @@ abstract class PluginCommand extends Command
|
|||||||
Bootstrap\LoadPlugins::class,
|
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)) {
|
if (PluginManager::isPluginExists($answer)) {
|
||||||
throw new \RuntimeException('名称为 ' . $answer . ' 的插件已存在,请换个名字');
|
throw new \RuntimeException('名称为 ' . $answer . ' 的插件已存在,请换个名字');
|
||||||
}
|
}
|
||||||
|
if (is_dir(zm_dir($this->plugin_dir . '/' . $exp[1]))) {
|
||||||
|
throw new \RuntimeException('本插件名称的插件开发目录已经有相同名称,请先将同名插件的目录名修改,或修改本插件名称');
|
||||||
|
}
|
||||||
return $answer;
|
return $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,9 +131,4 @@ abstract class PluginCommand extends Command
|
|||||||
default => '未知模式'
|
default => '未知模式'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
||||||
{
|
|
||||||
return parent::execute($input, $output);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user