-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
46 lines (35 loc) · 701 Bytes
/
main.go
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
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/danprince/sietch/internal/builder"
)
func main() {
var shouldServe bool
flag.BoolVar(&shouldServe, "serve", false, "Serve & rebuild the site")
flag.Parse()
rootDir, _ := os.Getwd()
mode := builder.Production
if shouldServe {
mode = builder.Development
}
b := builder.New(rootDir, mode)
// Start from a fresh slate each time the command is run
os.RemoveAll(b.OutDir)
os.MkdirAll(b.OutDir, 0755)
if shouldServe {
serve(b)
return
}
start := time.Now()
err := b.Build()
duration := time.Since(start)
if err != nil {
fmt.Println(err)
os.Exit(1)
} else {
fmt.Printf("built site (%s)\n", duration)
}
}