<commit_before>defmodule ElixirScript.Watcher do
  use GenServer
  require Logger

  def start_link(input, options) do
    GenServer.start_link(__MODULE__, [input: input, options: options])
  end

  def init(args) do
    {:ok, _} = Application.ensure_all_started(:elixir_script)
    :fs.subscribe()
    {:ok, args}
  end

  def handle_info({_pid, {:fs, :file_event}, {path, event}}, state) do
    Logger.debug "File changed: #{path}"
    ElixirScript.compile_path(state[:input], state[:options])
    {:noreply, state}
  end
end<commit_msg>Only acting on changes in the input folder<commit_after>defmodule ElixirScript.Watcher do
  use GenServer
  require Logger

  def start_link(input, options) do
    GenServer.start_link(__MODULE__, [input: input, options: options])
  end

  def init(args) do
    {:ok, _} = Application.ensure_all_started(:elixir_script)
    :fs.subscribe()
    {:ok, args}
  end

  def handle_info({_pid, {:fs, :file_event}, {path, event}}, state) do

    try do
      if input_changed?(to_string(path), state) do
        Logger.debug "Event: #{inspect event} Path: #{path}"
        ElixirScript.compile_path(state[:input], state[:options])
      end
    rescue
      x ->
        Logger.error(x.message)
    end

    {:noreply, state}
  end

  defp input_changed?(path, state) do
    file = Path.basename(path)

    case file do
      "." <> _ ->
        false
      _ ->
       path == Path.absname(Path.join([state[:input], file]))
    end
  end
end
{'fraction_non_alphanumeric': 0.1282225237449118, 'fraction_numerical': 0.0, 'mean_word_length': 3.3002915451895043, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6859838', 'n_tokens_mistral': 506, 'n_tokens_neox': 488, 'n_words': 122}