diff --git a/lib/mix/tasks/pre_dot_hn/clean.ex b/lib/mix/tasks/pre_dot_hn/clean.ex new file mode 100644 index 0000000..7ce5dac --- /dev/null +++ b/lib/mix/tasks/pre_dot_hn/clean.ex @@ -0,0 +1,7 @@ +defmodule Mix.Tasks.PreDotHn.Clean do + use Mix.Task + + def run(_args) do + PreDotHn.clean() + end +end diff --git a/lib/pre_dot_hn.ex b/lib/pre_dot_hn.ex index 8107768..98711d0 100644 --- a/lib/pre_dot_hn.ex +++ b/lib/pre_dot_hn.ex @@ -36,6 +36,20 @@ defmodule PreDotHn do def validate(other), do: {:ok, other} + def clean() do + "priv/static/**" + |> Path.wildcard() + |> Enum.each(fn path -> + if File.dir?(path) do + if !File.exists?(Path.join(path, ".keep")) do + File.exists?(path) && File.rm_rf!(path) + end + else + File.exists?(path) && File.rm!(path) + end + end) + end + def run() do posts = "site/**/*.md"