Mike Fikes mentioned that he's suggested creating a cljs command for the command line that is similar to the current clj command. It sounds like a good idea that might take some time to get momentum. In the interim, you can create your own.
Advantage is that it doesn't pollute your deps.edn for non-javascript work.
- Add an alias to
~/.bash_profile
alias cljs='clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.217\"}}}" -m cljs.main'
alias cljs.='clj -Sdeps "{:paths [\".\"] :deps {org.clojure/clojurescript {:mvn/version \"1.10.217\"}}}" -m cljs.main'Run a simple command
cljs -re node -e "(+ 2 3)"Get help
cljs --helpLet's say you have a foo.cljs file with -main defined.
# foo.cljs
(ns foo)
(defn -main [& args]
(println "hello world"))Run it.
cljs. -re node -m fooLet's say you have a script named myscript.cljs.
# myscript.cljs
(defn do-something-cool []
(println "hello world"))
(do-something-cool)Run it.
cljs -re node myscript.cljsDisadvantage, will load the clojurescript.jar for all clj commands -- even non-javascript runs.
- Add clojurescript dep to
~/.clojure/deps.edn
:deps {
org.clojure/clojurescript {:mvn/version "1.10.217"}
}- Add an alias to
~/.bash_profile
alias cljs='clj -m cljs.main'Run a simple command
cljs -re node -e "(+ 2 3)"Get help
cljs --help