raco pollen render: use first dir as project root (fixes #172)

pull/174/head
Matthew Butterick 7 years ago
parent f5b44bd337
commit 829bf2b421

@ -94,38 +94,39 @@ version print the version" (current-server-port) (make-publish-di
(define path-args (if (empty? parsed-args) (define path-args (if (empty? parsed-args)
(list (current-directory)) (list (current-directory))
parsed-args)) parsed-args))
(parameterize ([current-directory (current-project-root)] (parameterize ([current-poly-target (render-target-wanted)]) ;; applies to both cases
[current-poly-target (render-target-wanted)]) (cond
;; special case: one directory as argument ;; directory mode: one directory as argument
(if (and (= 1 (length path-args)) (directory-exists? (car path-args))) [(and (= 1 (length path-args)) (directory-exists? (car path-args)))
(let render-one-dir ([dir (->complete-path (car path-args))]) (define top-dir (very-nice-path (car path-args)))
(parameterize ([current-directory dir] (let render-one-dir ([dir top-dir])
[current-project-root (case (render-with-subdirs?) (parameterize ([current-directory dir]
[(recursive) dir] [current-project-root (if (eq? (render-with-subdirs?) 'recursive)
[else (current-project-root)])]) dir
(define dirlist (directory-list dir)) top-dir)])
(define preprocs (filter preproc-source? dirlist)) (define dirlist (directory-list dir))
(define static-pagetrees (filter pagetree-source? dirlist)) (define preprocs (filter preproc-source? dirlist))
;; if there are no static pagetrees, use make-project-pagetree (define static-pagetrees (filter pagetree-source? dirlist))
;; (which will synthesize a pagetree if needed, which includes all sources) ;; if there are no static pagetrees, use make-project-pagetree
(define batch-to-render ;; (which will synthesize a pagetree if needed, which includes all sources)
(map very-nice-path (define batch-to-render
(cond (map very-nice-path
[(null? static-pagetrees) (cond
(displayln (format "rendering generated pagetree for directory ~a" dir)) [(null? static-pagetrees)
(cdr (make-project-pagetree dir))] (displayln (format "rendering generated pagetree for directory ~a" dir))
[else (cdr (make-project-pagetree dir))]
(displayln (format "rendering preproc & pagetree files in directory ~a" dir)) [else
(append preprocs static-pagetrees)]))) (displayln (format "rendering preproc & pagetree files in directory ~a" dir))
(apply render-batch batch-to-render) (append preprocs static-pagetrees)])))
(when (render-with-subdirs?) (apply render-batch batch-to-render)
(for ([path (in-list dirlist)] (when (render-with-subdirs?)
#:when (and (directory-exists? path) (for ([path (in-list dirlist)]
(not (omitted-path? path)))) #:when (and (directory-exists? path)
(render-one-dir (->complete-path path)))))) (not (omitted-path? path))))
(begin (render-one-dir (->complete-path path))))))]
(displayln (format "rendering ~a" (string-join (map ->string path-args) " "))) [else ;; path mode
(apply render-batch path-args))))) (displayln (format "rendering ~a" (string-join (map ->string path-args) " ")))
(apply render-batch path-args)])))
(define (handle-start) (define (handle-start)

@ -1 +1 @@
1520467035 1521073365

Loading…
Cancel
Save