From c0bea10e669500c2521a513b009fc48827e0b78e Mon Sep 17 00:00:00 2001 From: Stefan Breunig <307954+breunigs@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:11:31 +0200 Subject: [PATCH] fix IO.Util.staleness when all target(s) or dependencies(s) were absent --- lib/util/io_util.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/util/io_util.ex b/lib/util/io_util.ex index f6dd6403..c158cec7 100644 --- a/lib/util/io_util.ex +++ b/lib/util/io_util.ex @@ -112,10 +112,10 @@ defmodule Util.IO do dep = Path.relative_to_cwd(dep_mod.newest.path) cond do - target_mod == nil -> + target_mod.oldest == nil -> {true, "target #{Path.relative_to_cwd(target)} doesn't exist"} - dep_mod == nil -> + dep_mod.newest == nil -> deps = dependencies |> Enum.map(&Path.relative_to_cwd/1) |> Enum.join(", ") {false, "none of the dependencies (#{deps}) exist"} @@ -127,7 +127,9 @@ defmodule Util.IO do end end - defp modification_times(paths) do + @typep file_time :: %{path: binary(), mtime: integer()} | nil + @spec modification_times(binary() | [binary()]) :: %{oldest: file_time(), newest: file_time()} + def modification_times(paths) do paths |> List.wrap() |> Parallel.flat_map(&include_descendants/1)