Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --print-classpath global option #321

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/nbb/impl/main.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns nbb.impl.main
(:require
["child_process" :as cproc]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you importing and not using?

["path" :as path]
[babashka.cli :as cli]
[clojure.string :as str]
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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)))
(->
Expand Down
4 changes: 3 additions & 1 deletion test/nbb/main_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down