Fix tests
This commit is contained in:
parent
28f9879e40
commit
4a1b26a6be
2 changed files with 12 additions and 11 deletions
|
|
@ -718,13 +718,12 @@ Use bb run --help to show this help output.
|
||||||
(defn parse-file-opt
|
(defn parse-file-opt
|
||||||
[options opts-map]
|
[options opts-map]
|
||||||
(let [opt (first options)]
|
(let [opt (first options)]
|
||||||
(if (and opt (fs/exists? opt))
|
(if (and opt (and (fs/exists? opt)
|
||||||
(let [opts (assoc opts-map
|
(not (fs/directory? opt))))
|
||||||
|
[(next options) (assoc opts-map
|
||||||
(if (str/ends-with? opt ".jar")
|
(if (str/ends-with? opt ".jar")
|
||||||
:jar :file) opt
|
:jar :file) opt)]
|
||||||
:command-line-args (next options))]
|
[options opts-map])))
|
||||||
opts)
|
|
||||||
opts-map)))
|
|
||||||
|
|
||||||
(defn parse-opts
|
(defn parse-opts
|
||||||
([options] (parse-opts options nil))
|
([options] (parse-opts options nil))
|
||||||
|
|
@ -744,7 +743,8 @@ Use bb run --help to show this help output.
|
||||||
(and (not (or (:file opts-map)
|
(and (not (or (:file opts-map)
|
||||||
(:jar opts-map)))
|
(:jar opts-map)))
|
||||||
(.isFile (io/file opt)))
|
(.isFile (io/file opt)))
|
||||||
(parse-file-opt options opts-map)
|
(let [[args opts] (parse-file-opt options opts-map)]
|
||||||
|
(assoc opts :command-line-args args))
|
||||||
(contains? tasks opt)
|
(contains? tasks opt)
|
||||||
(assoc opts-map
|
(assoc opts-map
|
||||||
:run opt
|
:run opt
|
||||||
|
|
@ -1144,11 +1144,12 @@ Use bb run --help to show this help output.
|
||||||
(list* "--jar" bin-jar "--" args)
|
(list* "--jar" bin-jar "--" args)
|
||||||
args)
|
args)
|
||||||
[args opts] (parse-global-opts args)
|
[args opts] (parse-global-opts args)
|
||||||
{:keys [jar file config merge-deps] :as opts}
|
;; TODO: drop jar file from opts
|
||||||
|
[args {:keys [jar file config merge-deps] :as opts}]
|
||||||
(if-not (or (:file opts)
|
(if-not (or (:file opts)
|
||||||
(:jar opts))
|
(:jar opts))
|
||||||
(parse-file-opt args opts)
|
(parse-file-opt args opts)
|
||||||
opts)
|
[args opts])
|
||||||
abs-path #(-> % io/file .getAbsolutePath)
|
abs-path #(-> % io/file .getAbsolutePath)
|
||||||
config (cond
|
config (cond
|
||||||
config (when (fs/exists? config) (abs-path config))
|
config (when (fs/exists? config) (abs-path config))
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
(parse-opts ["--force" "clojure" "-M" "-r"])))
|
(parse-opts ["--force" "clojure" "-M" "-r"])))
|
||||||
(testing "file opts parsing does not mess with :command-line-args"
|
(testing "file opts parsing does not mess with :command-line-args"
|
||||||
(is (= {:prn true, :expressions ["(prn :foo)"]}
|
(is (= {:prn true, :expressions ["(prn :foo)"]}
|
||||||
(-> (let [opts (main/parse-file-opt ["-e" "(prn :foo)"] {})]
|
(-> (let [[_ opts] (main/parse-file-opt ["-e" "(prn :foo)"] {})]
|
||||||
(main/parse-opts ["-e" "(prn :foo)"] opts)))))
|
(main/parse-opts ["-e" "(prn :foo)"] opts)))))
|
||||||
(is (= {:file "foo", :command-line-args ["README.md"]}
|
(is (= {:file "foo", :command-line-args ["README.md"]}
|
||||||
(main/parse-opts ["README.md"] {:file "foo"})))))
|
(main/parse-opts ["README.md"] {:file "foo"})))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue