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
|
||||
[options opts-map]
|
||||
(let [opt (first options)]
|
||||
(if (and opt (fs/exists? opt))
|
||||
(let [opts (assoc opts-map
|
||||
(if (str/ends-with? opt ".jar")
|
||||
:jar :file) opt
|
||||
:command-line-args (next options))]
|
||||
opts)
|
||||
opts-map)))
|
||||
(if (and opt (and (fs/exists? opt)
|
||||
(not (fs/directory? opt))))
|
||||
[(next options) (assoc opts-map
|
||||
(if (str/ends-with? opt ".jar")
|
||||
:jar :file) opt)]
|
||||
[options opts-map])))
|
||||
|
||||
(defn parse-opts
|
||||
([options] (parse-opts options nil))
|
||||
|
|
@ -744,7 +743,8 @@ Use bb run --help to show this help output.
|
|||
(and (not (or (:file opts-map)
|
||||
(:jar opts-map)))
|
||||
(.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)
|
||||
(assoc opts-map
|
||||
:run opt
|
||||
|
|
@ -1144,11 +1144,12 @@ Use bb run --help to show this help output.
|
|||
(list* "--jar" bin-jar "--" args)
|
||||
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)
|
||||
(:jar opts))
|
||||
(parse-file-opt args opts)
|
||||
opts)
|
||||
[args opts])
|
||||
abs-path #(-> % io/file .getAbsolutePath)
|
||||
config (cond
|
||||
config (when (fs/exists? config) (abs-path config))
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
(parse-opts ["--force" "clojure" "-M" "-r"])))
|
||||
(testing "file opts parsing does not mess with :command-line-args"
|
||||
(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)))))
|
||||
(is (= {:file "foo", :command-line-args ["README.md"]}
|
||||
(main/parse-opts ["README.md"] {:file "foo"})))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue