aboutsummaryrefslogtreecommitdiff
path: root/deepenv.scm
blob: 37082ad1bcce3ea7edc3985f07e4be0671d6c027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(import scheme
        (chicken base)
        (chicken pathname)
        (chicken file)
        (chicken io)
        (chicken string)
        (srfi srfi-13)
        (chicken process-context))

(define (dir-has-.env? dir)
  (file-exists? (make-pathname dir ".env")))

(define (read-env-line port)
  "Read an env-definition line from PORT and return as a cons cell"
  (let ((line (read-line port)))
    (string-split line "=")))

(define (load-dir-.env dir)
  "Load a .env file present in `.dir` and return its environment definitions as a alist"
  (with-input-from-file ".env"
    (lambda () (read-list (current-input-port) read-line))))

(letrec ((path-hierarchy (decompose-directory (current-directory)))))