Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/cortex/file_watcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule Cortex.FileWatcher do
use GenServer

@watched_dirs ["lib/", "test/", "apps/"]
@throttle_timer 100

##########################################
# Public API
Expand All @@ -28,14 +29,21 @@ defmodule Cortex.FileWatcher do

FileSystem.subscribe(watcher_pid)

{:ok, %{watcher_pid: watcher_pid}}
{:ok, %{watcher_pid: watcher_pid, throttling: false}}
end

def handle_info({:file_event, watcher_pid, {path, _events}},
%{watcher_pid: watcher_pid} = state) do
GenServer.cast(Controller, {:file_changed, file_type(path), path})
%{watcher_pid: watcher_pid, throttling: throttling} = state) do
unless throttling do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: throttling? as the var

GenServer.cast(Controller, {:file_changed, file_type(path), path})
Process.send_after(self(), :throttle_timer_complete, @throttle_timer)
end

{:noreply, state}
{:noreply, %{state | throttling: true}}
end

def handle_info(:throttle_timer_complete, state) do
{:noreply, %{state | throttling: false}}
end

def handle_info({:file_event, watcher_pid, :stop}, %{watcher_pid: watcher_pid} = state) do
Expand Down
2 changes: 1 addition & 1 deletion lib/cortex/test_runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ defmodule Cortex.TestRunner do
do: ExUnit.configure(exclude: [:test], include: focus)


defp clear_focus(),
defp clear_focus,
do: ExUnit.configure(exclude: [], include: [])


Expand Down