-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rkt
41 lines (34 loc) · 1 KB
/
main.rkt
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
#lang racket
#|
Ensures config is sane, dependencies exist,
then sends it off to the scanner.
|#
(require racket/path
racket/date
"modules/scan.rkt"
"modules/collate/main.rkt"
(file "~/.config/plato/config.rkt"))
(date-display-format 'iso-8601)
(define (ensure-exists config)
;; ensure directories in config exists
(for ([path-atom '(output-root output-entries)])
(let ([path (dict-ref config path-atom)])
(make-directory* (string->path path)))))
; This will benefit from a threading macro
; http://www.greghendershott.com/2013/05/the-threading-macro.html
(define (ensure-trailing-slashes config)
(dict-set!
config
'input-roots
(map (lambda (s) (string-append s "/"))
(map path->string
(map normalize-path
(dict-ref config 'input-roots))))))
;; send all assets to dispatcher
(define (main config)
(ensure-exists config)
(ensure-trailing-slashes config)
(scan config)
(collate config))
;; here we go...
(main cfg)