diff --git a/CHANGELOG.md b/CHANGELOG.md index f372893d..c2f4d49e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ For a list of breaking changes, check [here](#breaking-changes). [Nbb](https://github.com/babashka/nbb): Scripting in Clojure on Node.js using [SCI](https://github.com/babashka/sci) +- [#320](https://github.com/babashka/nbb/issues/318): Add `--print-classpath` global option to print a classpath checking `nbb.edn` file + ## 1.2.173 - [#318](https://github.com/babashka/nbb/issues/318): fix `:local/root` deps in `nbb.edn` when not invoked from current directory diff --git a/src/nbb/impl/main.cljs b/src/nbb/impl/main.cljs index 5f6094d5..1b79e571 100644 --- a/src/nbb/impl/main.cljs +++ b/src/nbb/impl/main.cljs @@ -1,5 +1,6 @@ (ns nbb.impl.main (:require + ["child_process" :as cproc] ["path" :as path] [babashka.cli :as cli] [clojure.string :as str] @@ -58,6 +59,7 @@ (case farg ("--help" "-h") (assoc opts :help true) ("--version" "-v") (assoc opts :version true) + "--print-classpath" (assoc opts :print-classpath true) "-e" (recur (assoc opts :expr (first nargs)) (next nargs)) ("-m" "--main") @@ -109,6 +111,7 @@ Global options: --debug: print additional debug info. -cp / --classpath: set the classpath. + --print-classpath: prints the classpath string of deps used by nbb. Evaluation: @@ -151,6 +154,9 @@ Tooling: (when (:version opts) (println (str (nbb/cli-name) " v" (nbb/version))) (js/process.exit 0)) + (when (:print-classpath opts) + (println (.toString (cproc/execSync "bb --config nbb.edn print-deps --format classpath"))) + (js/process.exit 0)) (if (or script-file expr nrepl-server repl? bundle-opts) (do (sci/alter-var-root nbb/command-line-args (constantly (:args opts))) (-> diff --git a/test/nbb/main_test.cljs b/test/nbb/main_test.cljs index 129b9210..7830dc0b 100644 --- a/test/nbb/main_test.cljs +++ b/test/nbb/main_test.cljs @@ -55,7 +55,9 @@ (is (= {:nrepl-server true, :port "0.0.0.0"} (main/parse-args ["nrepl-server" "--port" "0.0.0.0" ]))) (is (= {:config "../foo/nbb.edn"} - (main/parse-args ["--config" "../foo/nbb.edn"])))) + (main/parse-args ["--config" "../foo/nbb.edn"]))) + (is (= {:print-classpath true} + (main/parse-args ["--print-classpath"])))) (deftest-async simple-require-test (-> (nbb/load-string "(ns foo (:require cljs.core clojure.set))