summaryrefslogtreecommitdiff
path: root/book/src/main/scala/book/Main.scala
blob: 9b06d29cd739ae48d06053ad62a4e881510106de (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
34
35
36
package book

import java.io.InputStream
import java.nio.charset.StandardCharsets
import java.nio.file.{Paths, Files}

import scala.collection.mutable
import scalatags.Text.all._
import scalatags.Text.tags2


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.txt, "output/index.html")

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


}