warn on unknown files in output dir
this helps you clean up files if you delete a source file but don't delete the corresponding output target
This commit is contained in:
parent
cdc1a9efb7
commit
7f3d75abca
|
@ -7,7 +7,7 @@
|
|||
(require racket/bool racket/file racket/match racket/set
|
||||
syntax/parse/define (for-syntax racket/base racket/syntax))
|
||||
|
||||
(provide define-rule define-rule*
|
||||
(provide define-rule define-rule* rule-name rule-inputs rule-output
|
||||
generate-operations execute-rule execute-operations generate/execute)
|
||||
|
||||
;; A compiler rule
|
||||
|
|
12
render.rkt
12
render.rkt
|
@ -334,7 +334,17 @@
|
|||
(ir-doc->page xrefs-repo config)
|
||||
(write-string out)))
|
||||
output-rule))
|
||||
(append intermediate-rules output-rules img-rules static-rules (list scss hashtag-page)))
|
||||
(define all-rules (append intermediate-rules output-rules img-rules static-rules (list scss hashtag-page)))
|
||||
(define existing-output-files
|
||||
(parameterize ([current-directory output-dir])
|
||||
(for/set ([file (in-directory #f)] #:when (file-exists? file))
|
||||
(build-path output-dir file))))
|
||||
(define accounted-output-files
|
||||
(for/set ([rule (in-list all-rules)]) (rule-output rule)))
|
||||
(define unknown-output-files (set-subtract existing-output-files accounted-output-files))
|
||||
(for ([f (in-set unknown-output-files)])
|
||||
(printf "WARN: unknown file in output dir: ~a\n" f))
|
||||
all-rules)
|
||||
|
||||
(module+ main
|
||||
(require racket/cmdline)
|
||||
|
|
Loading…
Reference in New Issue