-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.vbs
67 lines (58 loc) · 1.79 KB
/
build.vbs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Option Explicit
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = CreateObject("Wscript.Shell")
Dim haveExe : haveExe = False
Dim haveCSS : haveCSS = False
' download mdbook and mdbook-katex if no executable
If fso.FileExists("bin/mdbook.exe") AND fso.FileExists("bin/mdbook-katex.exe") Then
haveExe = True
End If
' download katex theme if not found
If fso.FileExists("katex.min.css") AND fso.FolderExists("theme/fonts") Then
haveCSS = True
End If
If haveExe AND haveCSS Then
Else
If haveExe Then
wsh.Run "download_static_css.vbs" , 0 , 1
Else
If haveCSS Then
wsh.Run "download_binaries.cmd" , 0 , 1
Else
wsh.Run "cmd /c ""(start /min .\download_binaries.cmd & start .\download_static_css.vbs)|pause""" , 0 , 1
End If
End If
End If
' run mdbook init if no book.toml
If fso.FileExists("book.toml") Then
Else
' check if .gitignore already exists
Dim init : init = "git"
Dim miss : miss = True
If fso.FileExists(".gitignore") Then
init = "none"
miss = False
End If
' run mdbook init
wsh.Run "bin\mdbook init --title='' --ignore=" & init , 1 , 1
' write lines to book.toml
Dim cfg : Set cfg = fso.OpenTextFile( "book.toml" , 8 , True )
cfg.WriteLine("[output.html]")
cfg.WriteLine("additional-css = [""katex.min.css""]")
cfg.WriteLine("[preprocessor.katex]")
cfg.WriteLine("after = [""links""]")
cfg.WriteLine("no-css = true")
cfg.Close
Set cfg = Nothing
' write lines to .gitignore
If miss Then
Set cfg = fso.OpenTextFile( ".gitignore" , 8 , True )
cfg.WriteLine("bin")
cfg.WriteLine("katex.min.css")
cfg.WriteLine("theme/fonts/KaTeX_*.*")
cfg.Close
Set cfg = Nothing
End If
End If
' build and open book
wsh.Run "bin\mdbook build --open"