-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.exs
More file actions
39 lines (39 loc) · 1.17 KB
/
Copy pathtest.exs
File metadata and controls
39 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Enum.each(Path.wildcard("pages/posts/*.md"), fn file ->
content = File.read!(file)
case String.split(content, ~r/\r?\n---\r?\n/, parts: 2) do
[frontmatter, _body] ->
if String.starts_with?(frontmatter, "%{") do
try do
Code.eval_string(frontmatter, [])
rescue
e ->
IO.puts("\n=== ERROR IN FRONTMATTER OF: #{file} ===")
IO.inspect(e)
IO.puts("FRONTMATTER CONTENTS:")
IO.puts(frontmatter)
IO.puts("===================")
catch
:error, e ->
IO.puts("\n=== CATCH IN FRONTMATTER OF: #{file} ===")
IO.inspect(e)
IO.puts("FRONTMATTER CONTENTS:")
IO.puts(frontmatter)
IO.puts("===================")
end
end
[single] ->
if String.starts_with?(single, "%{") do
try do
Code.eval_string(single, [])
rescue
e ->
IO.puts("\n=== ERROR IN ENTIRE FILE: #{file} ===")
IO.inspect(e)
catch
:error, e ->
IO.puts("\n=== CATCH IN ENTIRE FILE: #{file} ===")
IO.inspect(e)
end
end
end
end)