From 78f677b98b3e356dcb1fc69f5097a1050304f01b Mon Sep 17 00:00:00 2001 From: Robert Prehn <3952444+prehnRA@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:09:02 -0600 Subject: [PATCH] feat: Add clean mix task --- lib/mix/tasks/pre_dot_hn/clean.ex | 7 +++++++ lib/pre_dot_hn.ex | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 lib/mix/tasks/pre_dot_hn/clean.ex 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"