weavejester/environ

NodeJS compatibility

grav opened this issue · 3 comments

grav commented

Would it make sense to make environ a wrapper around process.env? I have some code that does at least part of it, and I'll try my luck with a pull request if it's at all a sensible feature:

(ns environ.core
  (:require [clojure.string :as str]))

(defn- s->k [s]
  (-> s
      str/lower-case
      (str/replace "_" "-")
      keyword))

(def env
  (->> js/process.env
       js/Object.keys
       js->clj
       (map (fn [k] [(s->k k) (aget js/process.env k)]))
       (into {})))

This is very interesting also for self-hosted Clojure environments like lumo.

grav commented

On second thought, it does make sense to me in a shared node/jvm context, so I went ahead and did a pr: #70

You don't need to close an issue because a PR is opened. The issue still exists until the PR is merged, after all.