This commit is contained in:
Michiel Borkent 2021-03-20 18:18:45 +01:00
parent 9b9c6f0d36
commit 4a58ad8c9f
2 changed files with 10 additions and 3 deletions

View file

@ -59,7 +59,7 @@
([deps-map {:keys [:aliases]}]
(when-let [paths (:paths deps-map)]
(cp/add-classpath (str/join cp/path-sep paths)))
(when-let [deps-map (not-empty (dissoc deps-map :paths))]
(when-let [deps-map (not-empty (dissoc deps-map :paths :tasks))]
(let [deps-map (assoc-in deps-map [:aliases :org.babashka/defaults]
'{:replace-paths [] ;; babashka sets paths manually
:classpath-overrides {org.clojure/clojure ""

View file

@ -650,8 +650,15 @@ Use -- to separate script command line args from bb command line args.
preloads (when @should-load-inits? (some-> (System/getenv "BABASHKA_PRELOADS") (str/trim)))
[expressions exit-code]
(cond expressions [expressions nil]
main [[(format "(ns user (:require [%1$s])) (apply %1$s/-main *command-line-args*)"
main)] nil]
main
(let [sym (symbol main)
ns? (namespace sym)
ns (or ns? sym)
var-name (if ns?
(name sym)
"-main")]
[[(format "(ns user (:require [%1$s])) (apply %1$s/%2$s *command-line-args*)"
ns var-name)] nil])
file (try [[(read-file file)] nil]
(catch Exception e
(error-handler e {:expression expressions