[#394] fix --nrepl-server without port

This commit is contained in:
Michiel Borkent 2020-04-30 20:39:38 +02:00
parent ced19281b1
commit d65bb61d7c
2 changed files with 9 additions and 6 deletions

View file

@ -70,10 +70,9 @@
(when features/transit? (when features/transit?
(require '[babashka.impl.transit])) (require '[babashka.impl.transit]))
(binding [*unrestricted* true]
(sci/alter-var-root sci/in (constantly *in*)) (sci/alter-var-root sci/in (constantly *in*))
(sci/alter-var-root sci/out (constantly *out*)) (sci/alter-var-root sci/out (constantly *out*))
(sci/alter-var-root sci/err (constantly *err*))) (sci/alter-var-root sci/err (constantly *err*))
(set! *warn-on-reflection* true) (set! *warn-on-reflection* true)
;; To detect problems when generating the image, run: ;; To detect problems when generating the image, run:
@ -148,7 +147,7 @@
("--socket-repl") ("--socket-repl")
(let [options (next options) (let [options (next options)
opt (first options) opt (first options)
opt (when-not (str/starts-with? opt "-") opt (when (and opt (not (str/starts-with? opt "-")))
opt) opt)
options (if opt (next options) options (if opt (next options)
options)] options)]
@ -158,7 +157,7 @@
("--nrepl-server") ("--nrepl-server")
(let [options (next options) (let [options (next options)
opt (first options) opt (first options)
opt (when-not (str/starts-with? opt "-") opt (when (and opt (not (str/starts-with? opt "-")))
opt) opt)
options (if opt (next options) options (if opt (next options)
options)] options)]

View file

@ -17,6 +17,10 @@
(edn/read-string (apply test-utils/bb (when (some? input) (str input)) (map str args)))) (edn/read-string (apply test-utils/bb (when (some? input) (str input)) (map str args))))
(deftest parse-opts-test (deftest parse-opts-test
(is (= {:nrepl "1667"}
(main/parse-opts ["--nrepl-server"])))
(is (= {:socket-repl "1666"}
(main/parse-opts ["--socket-repl"])))
(is (= {:nrepl "1667", :classpath "src"} (is (= {:nrepl "1667", :classpath "src"}
(main/parse-opts ["--nrepl-server" "-cp" "src"]))) (main/parse-opts ["--nrepl-server" "-cp" "src"])))
(is (= {:socket-repl "1666", :expressions ["123"]} (is (= {:socket-repl "1666", :expressions ["123"]}