0 ? date(' ') . $text . PHP_EOL : PHP_EOL; } function create_dir(string $dir): void { if(!file_exists($dir) || !is_dir($dir)) { mkdir($dir); build_log("Created '{$dir}'!"); } } function glob_dir(string $dir, string $pattern, int $flags = 0): array { return glob($dir . '/' . $pattern, $flags); } function purge_dir(string $dir, string $pattern): void { $files = glob_dir($dir, $pattern); foreach($files as $file) { if(is_dir($file)) { build_log("'{$file}' is a directory, entering..."); purge_dir($file, $pattern); rmdir($file); } else { unlink($file); build_log("Deleted '{$file}'"); } } } $doAll = empty($argv[1]) || $argv[1] === 'all'; $doJs = $doAll || $argv[1] === 'js'; // Make sure we're running from the misuzu root directory. chdir(__DIR__); build_log('Cleanup'); if($doJs) { create_dir(JS_DIR); purge_dir(JS_DIR, '*.js'); purge_dir(TS_DIR, '*.d.ts'); build_log(); build_log('Compiling TypeScript'); build_log(shell_exec('tsc --extendedDiagnostics -p tsconfig.json')); } // no need to do this in debug mode, auto reload is enabled and cache is disabled if($doAll && !file_exists(__DIR__ . '/.debug')) { // Clear Twig cache build_log(); build_log('Deleting template cache'); purge_dir(TWIG_DIRECTORY, '*'); }