mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
增加删除临时目录的命令
This commit is contained in:
52
app/common/command/admin/Clear.php
Normal file
52
app/common/command/admin/Clear.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\command\admin;
|
||||||
|
|
||||||
|
use think\console\Command;
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\input\Argument;
|
||||||
|
use think\console\input\Option;
|
||||||
|
use think\console\Output;
|
||||||
|
use think\facade\App;
|
||||||
|
|
||||||
|
class Clear extends Command
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
// 指令配置
|
||||||
|
$this->setName('admin:clear')
|
||||||
|
->setDescription('删除开发临时生成目录');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output)
|
||||||
|
{
|
||||||
|
// 指令输出
|
||||||
|
$output->writeln('删除测试目录');
|
||||||
|
|
||||||
|
|
||||||
|
$command_line = '';
|
||||||
|
|
||||||
|
$dir = App::getRootPath() . '/runtime/source/';
|
||||||
|
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
$output->writeln('删除成功');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos(strtolower(PHP_OS), 'win') === 0) {
|
||||||
|
$command_line = implode(' ', ['rd', '/s', '/q', str_replace('/', '\\', $dir)]);
|
||||||
|
} else {
|
||||||
|
$command_line = implode(' ', ['rm', '-rf', $dir]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->info('删除目录:' . $command_line);
|
||||||
|
|
||||||
|
$output->info('run command: ' . $command_line);
|
||||||
|
|
||||||
|
exec($command_line);
|
||||||
|
|
||||||
|
$output->info('删除成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
// | 控制台配置
|
// | 控制台配置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use app\common\command\admin\Clear;
|
||||||
use app\common\command\admin\Version;
|
use app\common\command\admin\Version;
|
||||||
use app\common\command\admin\ResetPassword;
|
use app\common\command\admin\ResetPassword;
|
||||||
use app\common\command\curd\Migrate;
|
use app\common\command\curd\Migrate;
|
||||||
@@ -17,6 +18,7 @@ return [
|
|||||||
ResetPassword::class,
|
ResetPassword::class,
|
||||||
Timer::class,
|
Timer::class,
|
||||||
Version::class,
|
Version::class,
|
||||||
Migrate::class
|
Migrate::class,
|
||||||
|
Clear::class
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user