/
jack_in.cljs
3 lines (2 loc) · 1.65 KB
/
jack_in.cljs
1
2
3
(ns unravel.jack-in)
(def payload #_start "#!/usr/bin/env bash\n\nset -euo pipefail\n\nmake_command() {\n cmd=\"(do (require 'clojure.core.server) (let [srv (clojure.core.server/start-server {:name :repl :port 0 :accept 'clojure.core.server/repl :server-daemon false})] (println (str \\\\newline (pr-str [:jack-in/ready {:method :${1}, :port (.getLocalPort srv)}])))))\"\n}\n\ncheck_command() {\n if ! hash \"$1\" 2>/dev/null; then\n printf \"Trying to start a REPL automatically using jack-in method '%s'\\n\" \"$1\" 1>&2\n printf \"but the command '$1' was not found in your PATH.\\n\\n$2\\n\" 1>&2\n exit 1\n fi\n}\n\n\nif [[ \"${1-}\" == \"--method\" ]]; then\n method=\"$2\"\nelif [[ -e build.boot ]]; then\n method=boot\nelif [[ -e project.clj ]]; then\n method=lein\nelse\n method=clojure\nfi\n\ncase \"$method\" in\n boot)\n check_command \"boot\" \"For instructions on installing this tool see\\n\\nhttps://github.com/boot-clj/boot#install\"\n make_command boot\n exec boot call -e \"$cmd\" wait\n ;;\n lein)\n check_command \"lein\" \"For instructions on installing this tool see\\n\\nhttps://leiningen.org/\"\n make_command lein\n exec lein trampoline run -m clojure.main -e \"$cmd\"\n ;;\n clojure)\n check_command \"clojure\" \"For instructions on installing this tool see\\n\\nhttps://clojure.org/guides/getting_started\"\n make_command clojure\n exec clojure -e \"$cmd\"\n ;;\n *)\n echo Unknown method: \"$method\" 1>&2\n exit 1\nesac\n\n" #_end) ;; <!-- $RPLCR$ s:(#_start).*(#_end):$1." ".$ENV{PAYLOAD}." ".$2:e -->