From cad3e25f9645b2b7a5b064852ef8da934e23a2e7 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 28 Aug 2015 10:49:54 -0700 Subject: [PATCH] world settables can use file or dir path --- cache.rkt | 4 +--- render.rkt | 3 +-- world.rkt | 8 +++----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cache.rkt b/cache.rkt index 3ae5833..44d03da 100644 --- a/cache.rkt +++ b/cache.rkt @@ -145,11 +145,9 @@ (when (not (file-exists? path)) (error (format "cached-require: ~a does not exist" path))) - - (define-values (path-dir path-name _) (split-path path)) (cond - [(world:current-compile-cache-active path-dir) + [(world:current-compile-cache-active path) (define key (paths->key path)) (hash-ref (hash-ref! ram-cache key (λ _ (cache-ref! key (λ _ (path->hash path))))) subkey)] diff --git a/render.rkt b/render.rkt index 13f7067..061706e 100644 --- a/render.rkt +++ b/render.rkt @@ -96,8 +96,7 @@ (cond [(not (file-exists? output-path)) 'file-missing] [(mod-date-missing-or-changed? source-path template-path) 'mod-key-missing-or-changed] - [(let-values ([(source-dir source-name _) (split-path source-path)]) - (not (world:current-render-cache-active source-dir))) 'render-cache-deactivated] + [(not (world:current-render-cache-active source-path)) 'render-cache-deactivated] [else #f])) diff --git a/world.rkt b/world.rkt index c6efbb1..ae0f5ee 100644 --- a/world.rkt +++ b/world.rkt @@ -8,14 +8,12 @@ (define directory-require "pollen.rkt") -(define (get-path-to-override [starting-dir (current-directory)]) - ;; for now, let `path->complete-path` flag any argument errors (test here is redundant) - #;(when (or (not (path? starting-dir)) (not (directory-exists? starting-dir))) - (error 'get-path-to-override (format "~a is not a directory" starting-dir))) +(define (get-path-to-override [file-or-dir (current-directory)]) (define file-with-config-submodule directory-require) (define (dirname path) (let-values ([(dir name dir?) (split-path path)]) - dir)) + dir)) + (define starting-dir (if (directory-exists? file-or-dir) file-or-dir (dirname file-or-dir))) (let loop ([dir starting-dir][path file-with-config-submodule]) (and dir ; dir is #f when it hits the top of the filesystem (let ([completed-path (path->complete-path path starting-dir)])