Skip to content

Commit

Permalink
file watcher does not work on MacOS (#14)
Browse files Browse the repository at this point in the history
The original code was looking for a [:modified, :closed] event. However this is not emitted on MacOS, instead we should simply look if the events contains the :modified or :closed event.
  • Loading branch information
clemensm authored Nov 26, 2024
1 parent 2885668 commit dcb000e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/griffin_ssg/filesystem/watcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ defmodule GriffinSSG.Filesystem.Watcher do
{:ok, %{callback: callback}}
end

def handle_info({:file_event, _watcher_pid, {file_path, [:modified, :closed]}}, state) do
unless Path.extname(file_path) in @swap_file_extnames do
state.callback.()
def handle_info({:file_event, _watcher_pid, {file_path, events}}, state) do
if Enum.any?([:modified, :closed], & &1 in events) do
unless Path.extname(file_path) in @swap_file_extnames do
state.callback.()
end
end

{:noreply, state}
Expand Down

0 comments on commit dcb000e

Please sign in to comment.