summaryrefslogtreecommitdiff
path: root/book/src/main/scala/book/Main.scala
blob: 8ebcbd44f2d8c3469f4100cd99c3b187ff9f4f32 (plain) (blame)
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
package book
import acyclic.file
import java.io.InputStream
import java.nio.file.{Paths, Files}



object Main {
  def write(txt: String, dest: String) = {
    Paths.get(dest).toFile.getParentFile.mkdirs()
    Files.deleteIfExists(Paths.get(dest))
    Files.write(Paths.get(dest), txt.getBytes)
  }
  def copy(src: InputStream, dest: String) = {
    Paths.get(dest).toFile.getParentFile.mkdirs()
    Files.deleteIfExists(Paths.get(dest))
    Files.copy(src, Paths.get(dest))
  }

  def main(args: Array[String]): Unit = {
    println("Writing Book")

    write(Book.site, "output/index.html")

    for(res <- Book.autoResources ++ Book.manualResources) {
      copy(getClass.getResourceAsStream("/" + res), "output/" + res)
    }
    sect.structure
    println("Writing Done")
  }


}