Skip to content

Instantly share code, notes, and snippets.

@laheadle
Created December 16, 2022 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laheadle/0962ae6a265f53d1e43b03c9731d61c1 to your computer and use it in GitHub Desktop.
Save laheadle/0962ae6a265f53d1e43b03c9731d61c1 to your computer and use it in GitHub Desktop.
{:deps {cider/cider-nrepl {:mvn/version "0.28.3"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}}}
(ns org.stinkless.earth-book.tasks
(:require
[babashka.fs :as fs]
[babashka.tasks :refer [clojure shell]]
[clojure.java.io :as io]
[com.biffweb.tasks :as btasks]))
(defn run-args []
["-J-XX:-OmitStackTraceInFastThrow"
"-M" "-m" (:biff.tasks/main-ns @btasks/config)
"--port" "7888"
"--middleware" "[cider.nrepl/cider-middleware refactor-nrepl.middleware/wrap-refactor]"])
(defn tailwind-path []
"bin/tailwindcss")
(defn dev
"Starts the app locally.
After running, wait for the `System started` message. Connect your editor to
nrepl port 7888. Whenever you save a file, Biff will:
- Evaluate any changed Clojure files
- Regenerate static HTML and CSS files
- Run tests"
[& args]
(io/make-parents "target/resources/_")
(when (fs/exists? "package.json")
(shell "npm" "install"))
(when-not (fs/exists? (tailwind-path))
(btasks/install-tailwind))
(future (btasks/css "--watch"))
(spit ".nrepl-port" "7888")
(apply clojure {:extra-env {"BIFF_ENV" "dev"}}
(concat args (run-args))))
;; (defn hello
;; "An example of a custom task. See ./tasks/"
;; []
;; (println "Hello there."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment