Resolve relative slurp/io-reader paths against JOLT_PWD

io/file already resolved a relative path against JOLT_PWD (the user's cwd before
the launcher cd's to the repo root), but slurp and io/reader on a relative string
path opened it against the process cwd — so a program run from its own directory
couldn't read its own relative files (e.g. aero's (read-config "config.edn")).
Route the string branches through project-relative, matching io/file. Internal
callers pass already-resolved paths through read-file-string and are unaffected.
This commit is contained in:
Yogthos 2026-06-24 10:22:10 -04:00
parent d5deba2df8
commit b2bc52935d

View file

@ -211,7 +211,7 @@
;; a byte input-stream shim (e.g. clj-http-lite's :as :stream body): drain it. ;; a byte input-stream shim (e.g. clj-http-lite's :as :stream body): drain it.
((and (htable? src) (jolt-truthy? (jolt-ref-get src (keyword "jolt" "input-stream")))) ((and (htable? src) (jolt-truthy? (jolt-ref-get src (keyword "jolt" "input-stream"))))
(decode-bytevector (drain-byte-stream src) (slurp-encoding opts))) (decode-bytevector (drain-byte-stream src) (slurp-encoding opts)))
((string? src) (read-file-string src)) ((string? src) (read-file-string (project-relative src)))
(else (error #f "slurp: unsupported source" src)))) (else (error #f "slurp: unsupported source" src))))
(define (spit-append? opts) (define (spit-append? opts)
@ -300,7 +300,7 @@
((embedded-res? x) (host-new "StringReader" (embedded-res-content x))) ((embedded-res? x) (host-new "StringReader" (embedded-res-content x)))
((and (jhost? x) (string=? (jhost-tag x) "url")) ((and (jhost? x) (string=? (jhost-tag x) "url"))
(host-new "StringReader" (read-file-string (url-strip-scheme (url-spec x))))) (host-new "StringReader" (read-file-string (url-strip-scheme (url-spec x)))))
((string? x) (host-new "StringReader" (read-file-string x))) ((string? x) (host-new "StringReader" (read-file-string (project-relative x))))
((or (cseq? x) (empty-list-t? x) (pvec? x)) ((or (cseq? x) (empty-list-t? x) (pvec? x))
(host-new "StringReader" (seq-source->string x))) (host-new "StringReader" (seq-source->string x)))
(else (host-new "StringReader" (jolt-str-render-one x))))) (else (host-new "StringReader" (jolt-str-render-one x)))))