Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-12-11 17:54:55 -0800
committerCatalin Mititiuc <webdevcat@proton.me>2024-12-11 17:54:55 -0800
commit192d65a059c7f359bb7e3bc8927fc2efd24de92e (patch)
treef7dbcc0645563be653e478769e507399c4f67cfc /lib
parent9e8392a939825a8920004922d51b123b1a92b6b9 (diff)
Clear converted markdown directory before running mix task
Diffstat (limited to 'lib')
-rw-r--r--lib/mix/tasks/pandoc.ex9
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 ->