diff --git a/src/Templating/TemplatingContext.php b/src/Templating/TemplatingContext.php index 67630dc5..a96bf551 100644 --- a/src/Templating/TemplatingContext.php +++ b/src/Templating/TemplatingContext.php @@ -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, diff --git a/tools/nuke-tpl-cache b/tools/nuke-tpl-cache new file mode 100755 index 00000000..3dbd8847 --- /dev/null +++ b/tools/nuke-tpl-cache @@ -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}`;