Skip to content

Commit

Permalink
Manually expand glob expression in watch_files
Browse files Browse the repository at this point in the history
As file_system does not support globs, at least not on Linux.
  • Loading branch information
maltoe committed May 15, 2024
1 parent da7fcac commit 2ac33ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/lightning_css/runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ defmodule LightningCSS.Runner do
watcher_pid =
case {watch, config[:watch_files]} do
{true, glob} when is_binary(glob) ->
dirs = Path.join(cd, glob)
Logger.info("Watching #{dirs}")
{:ok, watcher_pid} = FileSystem.start_link(dirs: [dirs])
dirs = expand_glob(Path.join(cd, glob))
{:ok, watcher_pid} = FileSystem.start_link(dirs: dirs)
FileSystem.subscribe(watcher_pid)
watcher_pid

Expand All @@ -50,6 +49,13 @@ defmodule LightningCSS.Runner do
{:ok, args}
end

defp expand_glob(watch_files) do
watch_files
|> List.wrap()
|> Enum.flat_map(&Path.wildcard/1)
|> Enum.uniq()
end

def run_lightning_css(%{
config: config,
extra_args: extra_args,
Expand Down

0 comments on commit 2ac33ed

Please sign in to comment.