Skip to content

Commit

Permalink
New clear:lock command
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Feb 22, 2024
1 parent 1b7d168 commit 0245f29
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This should print the Kirby CLI version and a list of available commands
```
- kirby clean:content
- kirby clear:cache
- kirby clear:lock
- kirby clear:media
- kirby clear:sessions
- kirby download
Expand Down
23 changes: 23 additions & 0 deletions commands/clear/lock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types = 1);

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

return [
'description' => 'Deletes the content `.lock` files',
'command' => static function (CLI $cli): void {
$path = $cli->kirby()->root('content');
$directoryIterator = new RecursiveDirectoryIterator($path);
$iterator = new RecursiveIteratorIterator($directoryIterator);

foreach ($iterator as $file) {
if ($file->getFilename() === '.lock') {
F::remove($file->getPathName());
}
}

$cli->success('The lock files has been deleted');
}
];

0 comments on commit 0245f29

Please sign in to comment.