Get rid of conch
This commit is contained in:
parent
e6905173b6
commit
e6b211a030
3 changed files with 159 additions and 173 deletions
|
|
@ -67,8 +67,7 @@
|
|||
:feature/hiccup
|
||||
:feature/test-check
|
||||
:feature/spec-alpha
|
||||
{:dependencies [[clj-commons/conch "0.9.2"]
|
||||
[com.clojure-goes-fast/clj-async-profiler "0.4.1"]
|
||||
{:dependencies [[com.clojure-goes-fast/clj-async-profiler "0.4.1"]
|
||||
[com.opentable.components/otj-pg-embedded "0.13.3"]]}]
|
||||
:uberjar {:global-vars {*assert* false}
|
||||
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
|
||||
|
|
|
|||
|
|
@ -362,7 +362,22 @@ Use -- to separate script command line args from bb command line args.
|
|||
(println msg)
|
||||
{:exec (fn [] [nil exit])}))
|
||||
|
||||
(def ^:dynamic *bb-edn*
|
||||
(delay
|
||||
(let [bb-edn-file (or (System/getenv "BABASHKA_EDN")
|
||||
"bb.edn")]
|
||||
(when (fs/exists? bb-edn-file)
|
||||
(edn/read-string (slurp bb-edn-file))))))
|
||||
|
||||
(defn parse-opts [options]
|
||||
(let [fst (when options (first options))
|
||||
key? (when fst (str/starts-with? fst ":"))
|
||||
k (when key? (keyword (subs fst 1)))
|
||||
bb-edn (when k @*bb-edn*)
|
||||
tasks (when (and k bb-edn)
|
||||
(:tasks bb-edn))
|
||||
user-task (when tasks (get tasks k))]
|
||||
(if user-task (resolve-task user-task {:command-line-args (next options)})
|
||||
(let [opts (loop [options options
|
||||
opts-map {}]
|
||||
(if options
|
||||
|
|
@ -469,7 +484,7 @@ Use -- to separate script command line args from bb command line args.
|
|||
(assoc opts-map :main (first options))))
|
||||
(":do")
|
||||
(let [options (next options)
|
||||
options (into [] (comp (partition-by #(= % ":__"))
|
||||
options (into [] (comp (partition-by #(= % ":--"))
|
||||
(take-nth 2))
|
||||
options)
|
||||
parsed (map parse-opts options)]
|
||||
|
|
@ -497,37 +512,9 @@ Use -- to separate script command line args from bb command line args.
|
|||
(if (str/ends-with? opt ".jar")
|
||||
:jar :file) opt
|
||||
:command-line-args (next options))
|
||||
(if (str/starts-with? opt ":")
|
||||
(resolve-task opt {:command-line-args (next options)})
|
||||
(error (str "File does not exist: " opt) 1))))))))
|
||||
(error (str "File does not exist: " opt) 1)))))))
|
||||
opts-map))]
|
||||
opts))
|
||||
|
||||
(def bb-edn
|
||||
(delay
|
||||
(let [bb-edn-file (or (System/getenv "BABASHKA_EDN")
|
||||
"bb.edn")]
|
||||
(when (fs/exists? bb-edn-file)
|
||||
(edn/read-string (slurp bb-edn-file))))))
|
||||
|
||||
(defn resolve-task [task {:keys [:command-line-args]}]
|
||||
(if @bb-edn
|
||||
(if-let [task (get-in @bb-edn [:tasks (keyword (subs task 1))])]
|
||||
(case (:task/type task)
|
||||
:babashka
|
||||
(let [cmd-line-args (get task :args)]
|
||||
(parse-opts (seq (map str (concat cmd-line-args command-line-args)))))
|
||||
:shell
|
||||
(let [args (get task :args)
|
||||
args (into (vec args) command-line-args)]
|
||||
{:exec (fn []
|
||||
[nil
|
||||
(-> (p/process args {:inherit true})
|
||||
p/check
|
||||
:exit)])})
|
||||
(error (str "No such task: " (:task/type task)) 1))
|
||||
(error (str "No such task: " task) 1))
|
||||
(error (str "File does not exist: " task) 1)))
|
||||
opts))))
|
||||
|
||||
(def should-load-inits?
|
||||
"if true, then we should still load preloads and user.clj"
|
||||
|
|
@ -752,7 +739,7 @@ Use -- to separate script command line args from bb command line args.
|
|||
[& args]
|
||||
(handle-pipe!)
|
||||
(handle-sigint!)
|
||||
(when-let [bb-edn @bb-edn]
|
||||
(when-let [bb-edn @*bb-edn*]
|
||||
(deps/add-deps bb-edn))
|
||||
(if-let [dev-opts (System/getenv "BABASHKA_DEV")]
|
||||
(let [{:keys [:n]} (if (= "true" dev-opts) {:n 1}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
(:require
|
||||
[babashka.impl.classpath :as cp]
|
||||
[babashka.main :as main]
|
||||
[me.raynes.conch :refer [let-programs] :as sh]
|
||||
[babashka.process :as p]
|
||||
[sci.core :as sci]
|
||||
[sci.impl.vars :as vars]))
|
||||
|
||||
|
|
@ -43,15 +43,15 @@
|
|||
(vars/bindRoot sci/err *err*)))))
|
||||
|
||||
(defn bb-native [input & args]
|
||||
(let-programs [bb "./bb"]
|
||||
(try (if input
|
||||
(apply bb (conj (vec args)
|
||||
{:in input}))
|
||||
(apply bb args))
|
||||
(catch Exception e
|
||||
(let [d (ex-data e)
|
||||
err-msg (or (:stderr (ex-data e)) "")]
|
||||
(throw (ex-info err-msg d)))))))
|
||||
(let [res (p/process (into ["./bb"] args)
|
||||
{:in input
|
||||
:out :string
|
||||
:err :string})
|
||||
res (deref res)
|
||||
exit (:exit res)
|
||||
error? (pos? exit)]
|
||||
(if error? (throw (ex-info (or (:err res) "") {}))
|
||||
(:out res))))
|
||||
|
||||
(def bb
|
||||
(case (System/getenv "BABASHKA_TEST_ENV")
|
||||
|
|
|
|||
Loading…
Reference in a new issue