Skip to content

Commit f3244ba

Browse files
committed
Fix handling of user-provided -e args
Closes #58
1 parent 14cecde commit f3244ba

File tree

7 files changed

+38
-6
lines changed

7 files changed

+38
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ install-deps: install-base
2020
install-plugin: install-base
2121
cd lein-plugin; lein with-profile -user install
2222

23-
# Usage: PROJECT_VERSION=1.18.6 make install
23+
# Usage: PROJECT_VERSION=1.19.0 make install
2424
# PROJECT_VERSION is needed because it's not computed dynamically
2525
install: install-base install-deps install-plugin
2626

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DEPS_MAIN_OPTS ?= "-M:dev:test"
3030

3131
# The enrich-classpath version to be injected.
3232
# Feel free to upgrade this.
33-
ENRICH_CLASSPATH_VERSION="1.18.6"
33+
ENRICH_CLASSPATH_VERSION="1.19.0"
3434

3535
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
3636
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.

lein-plugin/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ DEPS_MAIN_OPTS ?= "-M:dev:test"
2727

2828
# The enrich-classpath version to be injected.
2929
# Feel free to upgrade this.
30-
ENRICH_CLASSPATH_VERSION="1.18.6"
30+
ENRICH_CLASSPATH_VERSION="1.19.0"
3131

3232
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
3333
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.

tools.deps/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ DEPS_MAIN_OPTS ?= "-M:dev:test"
2727

2828
# The enrich-classpath version to be injected.
2929
# Feel free to upgrade this.
30-
ENRICH_CLASSPATH_VERSION="1.18.6"
30+
ENRICH_CLASSPATH_VERSION="1.19.0"
3131

3232
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
3333
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.

tools.deps/src/cider/enrich_classpath/clojure.clj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@
5959
args (into []
6060
(remove (hash-set main extra-flag extra-value))
6161
args)
62+
eval-option (atom [])
63+
args (reduce-kv (fn [acc ^long i x]
64+
(let [j (dec i)]
65+
(cond
66+
(#{"-e" (pr-str "-e")} x)
67+
(do
68+
(swap! eval-option conj x)
69+
acc)
70+
71+
(and (>= j 0)
72+
(#{"-e" (pr-str "-e")} (nth args j)))
73+
(do
74+
(swap! eval-option conj (pr-str x))
75+
acc)
76+
77+
:else
78+
(conj acc x))))
79+
[]
80+
args)
6281
main-opts (reduce-kv (fn [acc ^long i x]
6382
(let [j (dec i)]
6483
(conj acc (cond-> x
@@ -218,6 +237,7 @@
218237
[]
219238
(mapv (partial str "-J")
220239
calculated-jvm-opts)))
240+
(into @eval-option)
221241
(into (if (seq main-opts)
222242
main-opts
223243
[]))

tools.deps/src/cider/enrich_classpath/clojure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ else
3737
cd "$there"
3838

3939
# enrich-classpath will emit a command starting by "clojure", or print a stacktrace:
40-
output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.18.6"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@")
40+
output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.19.0"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@")
4141
cmd=$(tail -n1 <(echo "$output"))
4242

4343
cd "$here"

tools.deps/test/integration/cider/enrich_classpath/clojure.clj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,19 @@
149149
["-A:eval"]
150150
false)]
151151
(is (string/includes? cp "-e \"(println \\\"foo\\\")\"")
152-
"Escapes the -e value")))
152+
"Escapes the -e value"))
153+
154+
(testing "https://github.com/clojure-emacs/enrich-classpath/issues/58"
155+
(let [^String cp (sut/impl "clojure"
156+
"deps.edn"
157+
(str (io/file (System/getProperty "user.dir") "test-resources" "eval"))
158+
["-e" "\"(+ 311 2)\""]
159+
false)]
160+
(is (string/ends-with? cp "-e \"\\\"(+ 311 2)\\\"\"")
161+
"Honors a user-provided `-e`, placing it at the correct position")
162+
(is (= (.indexOf cp "311")
163+
(.lastIndexOf cp "311"))
164+
"`-e` is effectively moved, so that it's not emitted twice"))))
153165

154166
(deftest path-aliases
155167
(let [cp (sut/impl "clojure"

0 commit comments

Comments
 (0)