consolidate functions

pull/9/head
Matthew Butterick 11 years ago
parent b64dd9f273
commit 5835f09a26

@ -1,26 +1,10 @@
#lang racket/base #lang racket/base
(require (for-syntax racket/base)) (require (for-syntax racket/base "../project-requires.rkt"))
(provide (all-defined-out)) (provide (all-defined-out))
;; A place to stash functions that don't change between compiles of Pollen files. ;; A place to stash functions that don't change between compiles of Pollen files.
;; duplicate of contents of project-require.rkt.
;; Goes faster if it's not in a separate module.
;; todo: use include? But this one has to be available as syntax
;; todo: get rid of magic value
(define-for-syntax (project-require-file? path)
(define path-string (path->string path))
(equal? (substring path-string (- (string-length path-string) 3) (string-length path-string)) "rkt"))
;; list of all eligible requires in project require directory
(define-for-syntax (get-project-require-files)
(define extras-directory (build-path (current-directory) "pollen-require"))
(and (directory-exists? extras-directory)
;; #:build? option returns complete paths (instead of just file names)
(let ([files (filter project-require-file? (directory-list extras-directory #:build? #t))])
(and (not (equal? '() files)) files))))
(define-for-syntax (put-file-in-require-form file) (define-for-syntax (put-file-in-require-form file)
`(file ,(path->string file))) `(file ,(path->string file)))

@ -14,7 +14,3 @@
;; #:build? option returns complete paths (instead of just file names) ;; #:build? option returns complete paths (instead of just file names)
(let ([files (filter project-require-file? (directory-list extras-directory #:build? #t))]) (let ([files (filter project-require-file? (directory-list extras-directory #:build? #t))])
(and (not (equal? null files)) files)))) (and (not (equal? null files)) files))))
(module+ main
(parameterize ([world:current-project-root (string->path "/Users/mb/git/bpt/")])
(get-project-require-files)))
Loading…
Cancel
Save