Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active January 6, 2024 07:13
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mfikes/18d2f8109c938880382a5d355eb08a7e to your computer and use it in GitHub Desktop.
Save mfikes/18d2f8109c938880382a5d355eb08a7e to your computer and use it in GitHub Desktop.
cljs command

If you wan't a cljs that acts like clj, but for ClojureScript, there are a few minor changes you can make:

First, add the following entry to ~/.clojure/deps.edn under the :deps key:

org.clojure/clojurescript {:mvn/version "1.10.439"}

Then make copies of clj and clojure named cljs and clojurescript, and put those copies on your path.

For the clojurescript script, remove the help flag handler and add -m cljs.main:

$ diff `which clojure` `which clojurescript`
98,105d97
<     -h|--help|"-?")
<       if [[ ${#main_aliases[@]} -gt 0 ]] || [[ ${#all_aliases[@]} -gt 0 ]]; then
<         break
<       else
<         help=true
<         shift
<       fi
<       ;;
344c336
<   exec "$JAVA_CMD" "${jvm_cache_opts[@]}" "${jvm_opts[@]}" "-Dclojure.libfile=$libs_file" -classpath "$cp" clojure.main "${main_cache_opts[@]}" "$@"
---
>   exec "$JAVA_CMD" "${jvm_cache_opts[@]}" "${jvm_opts[@]}" "-Dclojure.libfile=$libs_file" -classpath "$cp" clojure.main "${main_cache_opts[@]}" -m cljs.main "$@"

and for the cljs script, change clojure to clojurescript:

$ diff `which clj` `which cljs`
4c4
<   exec rlwrap -r -q '\"' -b "(){}[],^%#@\";:'" clojure "$@"
---
>   exec rlwrap -r -q '\"' -b "(){}[],^%#@\";:'" clojurescript "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment