summaryrefslogtreecommitdiff
path: root/book/src/main/scala/book/Main.scala
blob: 89fb5e1f885888a11d2a535a1a41da30bc9ce09f (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
37
38
39
40
41
42
43
44
package book

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

import org.eclipse.jgit.api.Git

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")
//    Files.deleteIfExists(Paths.get("output/temp"))
//    Git.cloneRepository()
//       .setURI("https://github.com/lihaoyi/workbench-example-app")
//       .setDirectory(new java.io.File("output/temp"))
//       .call()


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

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


}