◊(Local Yarn Code "path.rkt at [cf83a366]")

File yarn-lib/path.rkt artifact 6ad5fb98 part of check-in cf83a366


#lang racket/base

; SPDX-License-Identifier: BlueOak-1.0.0
; This file is licensed under the Blue Oak Model License 1.0.0.

(require pollen/core
         pollen/file
         pollen/setup
         racket/path)

(provide here-source-path
         here-output-path)

(define (identity v) v)

;; Return the path to the current Pollen source, relative to project root
(define (here-source-path #:string? [string? #t])
  (define proc (if string? path->string identity))
  (cond
    [(current-metas)
     (proc (find-relative-path (current-project-root) (hash-ref (current-metas) 'here-path)))]
    [else "."]))

;; Return the path to the output filename for the current Pollen source,
;; relative to project root
(define (here-output-path #:string? [string? #t])
  (define proc (if string? path->string identity))
  (proc (->output-path (here-source-path #:string? #f))))