Added utility to nuke the templating cache directory.

This commit is contained in:
flash 2025-04-03 20:01:27 +00:00
parent 155b301405
commit 9d70505ad8
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
2 changed files with 18 additions and 1 deletions

View file

@ -11,7 +11,7 @@ class TemplatingContext {
public function __construct(
Dependencies $deps,
string $cachePath,
public private(set) string $cachePath,
) {
$this->env = new TplEnvironment(
Misuzu::PATH_TEMPLATES,

17
tools/nuke-tpl-cache Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php
namespace Misuzu;
require_once __DIR__ . '/../misuzu.php';
$path = $msz->tplCtx->cachePath;
if(empty($path))
die(sprintf('No cache path is specified.%s', PHP_EOL));
if(!is_dir($path))
die(sprintf('Cache directory does not exist.%s', PHP_EOL));
if(fileowner($path) !== posix_getuid())
die(sprintf('Script must be run as the owner of the cache directory.%s', PHP_EOL));
echo `rm -rv {$path}`;