Skip to content

Commit

Permalink
Use PHP native functions
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Feb 26, 2024
1 parent 8aea2ae commit 92fc7a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions commands/plugin/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types = 1);

use Kirby\CLI\CLI;
use Kirby\Filesystem\Dir;

return [
'description' => 'Deletes a kirby plugin',
Expand All @@ -17,7 +16,7 @@
$repo = $cli->arg('repo');

if ($plugin = $cli->kirby()->plugin($repo)) {
Dir::remove($plugin->root());
$cli->rmdir($plugin->root());
$cli->success('The ' . $repo . ' plugin has been deleted');
} else {
$cli->error('The ' . $repo . ' plugin could not found');
Expand Down
3 changes: 1 addition & 2 deletions commands/plugin/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types = 1);

use Kirby\CLI\CLI;
use Kirby\Filesystem\F;

return [
'description' => 'Installs a kirby plugin repository from the Github',
Expand Down Expand Up @@ -45,7 +44,7 @@
$cli->run('unzip', $zip, $dir);

// remove the zip
F::unlink($zip);
unlink($zip);

$cli->success('The ' . $repo . ' plugin has been installed ' . $version . ' version');
}
Expand Down
11 changes: 6 additions & 5 deletions commands/plugin/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types = 1);

use Kirby\CLI\CLI;
use Kirby\Filesystem\Dir;

return [
'description' => 'Updates a kirby plugin',
Expand All @@ -23,13 +22,15 @@

if ($plugin = $cli->kirby()->plugin($repo)) {
try {
// move plugin directory to prevent overwrite
Dir::move($plugin->root(), $plugin->root() . '.bak');
// move plugin temp directory to prevent overwrite
rename($plugin->root(), $plugin->root() . '.temp');

$cli->run('plugin:install', $repo, $version);
Dir::remove($plugin->root() . '.bak');
$cli->rmdir($plugin->root() . '.bak');

$cli->success('The ' . $repo . ' plugin has been updated to ' . $version . ' version');
} catch (Throwable) {
Dir::move($plugin->root() . '.bak', $plugin->root());
rename($plugin->root() . '.bak', $plugin->root());
$cli->error('The ' . $repo . ' plugin could not updated');
}
} else {
Expand Down

0 comments on commit 92fc7a1

Please sign in to comment.