~mika/www.m1kadev.nl

ref: 3a6b96458aaa637309a1ceef651158071bd4de84 www.m1kadev.nl/kethel/main.exs -rw-r--r-- 1.1 KiB
3a6b9645 — m1kadev Implement easy static content 6 months ago
                                                                                
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
args = System.argv()

folder = Enum.at(args, 1)

if folder != nil do
  project_root = Path.expand(folder)

  File.rm_rf!("#{project_root}/build")
  File.mkdir_p("#{project_root}/build")

  # other contents depend on this, so we cant async it
  bricks = Bricks.collect(project_root)

  # special case, see module documentation
  statics_task = Task.async(fn -> Statics.compile(project_root) end)

  styles_task = Task.async(fn -> Styles.collect(project_root) end)
  pages_task = Task.async(fn -> Pages.collect(project_root, bricks) end)
  scripts_task = Task.async(fn -> Scripts.collect(project_root) end)

  [styles, pages, scripts] = Task.await_many([styles_task, pages_task, scripts_task], :infinity)

  pages_compile_task = Task.async(fn -> Pages.compile(pages) end)
  styles_compile_task = Task.async(fn -> Styles.compile(styles) end)
  scripts_compile_task = Task.async(fn -> Scripts.compile(scripts) end)

  Task.await_many(
    [pages_compile_task, styles_compile_task, statics_task, scripts_compile_task],
    :infinity
  )
else
  IO.puts(:stderr, "The root project folder should be provided on the command line")
end