Skip to content

Commit d0b64d7

Browse files
committed
remove configurability via env variables
* this does not play well with compilation caches * also we remove the only dependency we have
1 parent 3c04a77 commit d0b64d7

File tree

5 files changed

+6
-63
lines changed

5 files changed

+6
-63
lines changed

docs/configuration.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Configuration can be done on multiple levels (later overrides former levels):
66

77
1. defaults
88
2. compiler options
9-
3. environmental variables
10-
4. programmatically
9+
3. programmatically
1110

1211
### Configuration via defaults
1312

@@ -37,22 +36,6 @@ For example:
3736
This overrides default `:features-to-install`, sets custom `:fn-symbol` and instructs cljs-devtools to print overridden config
3837
values during installation.
3938

40-
### Configuration via environmental variables
41-
42-
We use [binaryage/env-config](https://github.com/binaryage/env-config) library to allow configuration overrides via
43-
environmental variables. Common prefix for our configuration variables is `CLJS_DEVTOOLS`.
44-
45-
For example, in a Bash shell you can do this to achieve configuration matching the config map above:
46-
47-
lein clean
48-
env CLJS_DEVTOOLS/FN_SYMBOL=F \
49-
CLJS_DEVTOOLS/PRINT_CONFIG_OVERRIDES=true \
50-
CLJS_DEVTOOLS/FEATURES_TO_INSTALL="~[:formatters :hints]" \
51-
lein cljsbuild once
52-
53-
Please note that environmental variables are retrieved during compilation in a macro expansion. So proper environment must
54-
be present during ClojureScript compilation and you have to clear compilation caches after changing the environment.
55-
5639
### Programmatic configuration
5740

5841
When [installed manually](https://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#install-it-manually),

project.clj

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
:url "https://github.com/binaryage/cljs-devtools"}
1111

1212
:dependencies [[org.clojure/clojure "1.10.1" :scope "provided"]
13-
[org.clojure/clojurescript ~clojurescript-version :scope "provided"]
14-
[binaryage/env-config "0.2.2"]]
13+
[org.clojure/clojurescript ~clojurescript-version :scope "provided"]]
1514

1615
:clean-targets ^{:protect false} ["target"
1716
"test/resources/.compiled"]
@@ -60,19 +59,6 @@
6059
:preloads [devtools.testenv]
6160
:optimizations :none
6261
:checked-arrays :warn}}
63-
:tests-with-config
64-
{:source-paths ["src/lib"
65-
"test/src/tests"]
66-
:compiler {:output-to "test/resources/.compiled/tests-with-config/build.js"
67-
:output-dir "test/resources/.compiled/tests-with-config"
68-
:asset-path ".compiled/tests-with-config"
69-
:main devtools.main
70-
:optimizations :none
71-
:checked-arrays :warn
72-
:external-config {:devtools/config {:features-to-install [:hints]
73-
:fn-symbol "F"
74-
:print-config-overrides true}}
75-
:preloads [devtools.testenv devtools.preload]}} ; CLJS-1688
7662
:dead-code
7763
{:source-paths ["src/lib"
7864
"test/src/dead-code"]
@@ -171,7 +157,6 @@
171157
:aliases {"test" ["do"
172158
["clean"]
173159
["test-tests"]
174-
["test-tests-with-config"]
175160
["test-dead-code"]
176161
;["test-dce-size"]
177162
["test-advanced-warning"]]

scripts/compile-tests-with-config.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/lib/devtools/prefs.clj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns devtools.prefs
2-
(:require [env-config.core :as env-config]
3-
[cljs.env]))
2+
(:require [cljs.env]))
43

54
; see https://github.com/binaryage/cljs-devtools/blob/master/docs/configuration.md
65

@@ -17,25 +16,15 @@
1716

1817
; -- environmental config ---------------------------------------------------------------------------------------------------
1918

20-
(def ^:dynamic env-config-prefix "cljs-devtools")
21-
2219
(defn get-env-vars []
2320
(-> {}
2421
(into (System/getenv))
2522
(into (System/getProperties))))
2623

27-
(defn read-env-config []
28-
(env-config/make-config-with-logging env-config-prefix (get-env-vars)))
29-
30-
(def memoized-read-env-config (memoize read-env-config))
31-
32-
(defmacro emit-env-config []
33-
`'~(or (memoized-read-env-config) {}))
34-
3524
; -- macro config api -------------------------------------------------------------------------------------------------------
3625

3726
(defn read-config []
38-
(merge (memoized-read-env-config) (read-external-config)))
27+
(read-external-config))
3928

4029
(def memoized-read-config (memoize read-config))
4130

src/lib/devtools/prefs.cljs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
(ns devtools.prefs
2-
(:require-macros [devtools.prefs :refer [emit-external-config emit-env-config]])
2+
(:require-macros [devtools.prefs :refer [emit-external-config]])
33
(:require [devtools.defaults :as defaults]))
44

55
; we use delay for DCE, see https://github.com/binaryage/cljs-devtools/issues/37
66
(def default-config (delay @defaults/config))
77
(def external-config (delay (emit-external-config)))
8-
(def env-config (delay (emit-env-config)))
9-
(def initial-config (delay (merge @default-config @external-config @env-config)))
8+
(def initial-config (delay (merge @default-config @external-config)))
109

1110
(def ^:dynamic *current-config* (delay @initial-config))
1211

0 commit comments

Comments
 (0)