Web Dev Solutions

Catalin Mititiuc

From 192d65a059c7f359bb7e3bc8927fc2efd24de92e Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 11 Dec 2024 17:54:55 -0800 Subject: Clear converted markdown directory before running mix task --- lib/mix/tasks/pandoc.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -> -- cgit v1.2.3