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:
xenia 2021-07-07 01:11:00 -04:00
parent cdc1a9efb7
commit 7f3d75abca
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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)