Skip to content

Commit

Permalink
feat: add keepCSS param in saveCSS method
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Nov 12, 2023
1 parent a063964 commit be46e16
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,18 @@ public function saveCSS(
$onlySuperuser = true,
$css = null,
$minify = false,
): string {
$keepCSS = true,
) {
// early exit?
if ($onlySuperuser && !$this->wire->user->isSuperuser()) return;

$css = $css ?: substr($less, 0, -5) . ".css";
if (!is_file($less)) return $css;

$mLESS = filemtime($less);
$mCSS = is_file($css) ? filemtime($css) : 0;

$sudoCheck = $onlySuperuser ? $this->wire->user->isSuperuser() : true;
if ($mLESS > $mCSS and $sudoCheck) {
if ($mLESS > $mCSS) {
if ($parser = $this->wire->modules->get('Less')) {
// recreate css file
/** @var Less $parser */
Expand All @@ -385,7 +388,9 @@ public function saveCSS(
}

if ($minify) {
return $this->minify($css);
$min = $this->minify($css);
if (!$keepCSS) $this->wire->files->unlink($css);
return $min;
}

return $css;
Expand Down

0 comments on commit be46e16

Please sign in to comment.