fork of anirudh.fi/vite that uses chroma for hl
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use goroutines for the keks

+35 -4
+35 -4
commands/build.go
··· 1 1 package commands 2 2 3 3 import ( 4 + "fmt" 4 5 "os" 5 6 "path/filepath" 6 7 "sort" 7 8 "strings" 9 + "sync" 8 10 "time" 9 11 10 12 "git.icyphox.sh/vite/atom" ··· 195 197 // Core builder function. Converts markdown to html, 196 198 // copies over non .md files, etc. 197 199 func Build() error { 200 + fmt.Print("vite: building... ") 198 201 pages := Pages{} 199 202 if err := pages.initPages(); err != nil { 200 203 return err ··· 205 208 return err 206 209 } 207 210 211 + wg := sync.WaitGroup{} 212 + wg.Add(2) 213 + wgDone := make(chan bool) 214 + 215 + ec := make(chan error) 216 + 208 217 // Deal with files. 209 218 // ex: pages/{_index,about,etc}.md 210 - if err := pages.processFiles(); err != nil { 211 - return err 212 - } 219 + go func() { 220 + err := pages.processFiles() 221 + if err != nil { 222 + ec <- err 223 + } 224 + wg.Done() 225 + }() 213 226 214 227 // Deal with dirs -- i.e. dirs of markdown files. 215 228 // ex: pages/{blog,travel}/*.md 216 - if err := pages.processDirs(); err != nil { 229 + go func() { 230 + err := pages.processDirs() 231 + if err != nil { 232 + ec <- err 233 + } 234 + wg.Done() 235 + }() 236 + 237 + go func() { 238 + wg.Wait() 239 + close(wgDone) 240 + }() 241 + 242 + select { 243 + case <-wgDone: 244 + break 245 + case err := <-ec: 246 + close(ec) 217 247 return err 218 248 } 219 249 ··· 225 255 return err 226 256 } 227 257 258 + fmt.Print("done\n") 228 259 return nil 229 260 }