Skip to content

Commit

Permalink
fix: prevent livereload from calling npm run build in the loop more t…
Browse files Browse the repository at this point in the history
…han once

This happened when multiple tabs where opened as the loop did not check if execution has already run
BernhardBaumrock committed Jul 9, 2024
1 parent 034f0e2 commit 4a787c4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion LiveReload.php
Original file line number Diff line number Diff line change
@@ -202,17 +202,19 @@ public function watch()

// start loop
$start = time();
$executed = false;
while (true) {
$file = $this->findModifiedFile($start);

// file changed
if ($file && $debug) {
if (!$executed && $file && $debug) {
$this->wire->log->save('livereload', "File changed: $file", $opt);
if ($build) {
$cmd = "npm run build";
$this->wire->log->save('livereload', "Rebuilding tailwind with '$cmd'", $opt);
exec($cmd);
}
$executed = true;
}

// send trigger to frontend

0 comments on commit 4a787c4

Please sign in to comment.