index : pandoc | |
Hex package with a file-watcher and Mix task for using Pandoc to convert Markdown files to HTML. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-12-11 17:54:55 -0800 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-12-11 17:54:55 -0800 |
commit | 192d65a059c7f359bb7e3bc8927fc2efd24de92e (patch) | |
tree | f7dbcc0645563be653e478769e507399c4f67cfc | |
parent | 9e8392a939825a8920004922d51b123b1a92b6b9 (diff) |
Clear converted markdown directory before running mix task
-rw-r--r-- | lib/mix/tasks/pandoc.ex | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/mix/tasks/pandoc.ex b/lib/mix/tasks/pandoc.ex index 94d7dd5..179eab8 100644 --- a/lib/mix/tasks/pandoc.ex +++ b/lib/mix/tasks/pandoc.ex @@ -24,8 +24,15 @@ defmodule Mix.Tasks.Pandoc do profile = String.to_atom(profile) config = Application.get_env(:pandoc, profile) + args = config[:args] || [] + opts = [cd: config[:cd] || File.cwd!()] - (config[:cd] || File.cwd!()) + out_path = List.last(args) + full_out_path = [opts[:cd], out_path] |> Path.join() |> Path.expand() + File.rm_rf!(full_out_path) + File.mkdir_p!(full_out_path) + + opts[:cd] |> Path.join("*#{@ext}") |> Path.wildcard() |> Enum.each(fn path -> |