Skip to content

Instantly share code, notes, and snippets.

@arichiardi
Created March 20, 2019 20:07
Show Gist options
  • Save arichiardi/521b449efb6e0c646b98ce1ed51bb905 to your computer and use it in GitHub Desktop.
Save arichiardi/521b449efb6e0c646b98ce1ed51bb905 to your computer and use it in GitHub Desktop.
Shadow-cljs cljs deps.edn hook
(ns user.shadow-build
(:require [cheshire.core :as json]
[clojure.java.io :as io]))
(def ^:private package-json-path "package.json")
(def ^:private deps-edn-path "src/deps.cljs")
(defn deps-cljs
[package-json-edn]
{:npm-deps (get package-json-edn "dependencies" {})})
(defn flush-hook
{:shadow.build/stage :flush}
[build-state & args]
(println "[:flush-hook] Update deps.cljs from package.json:")
(let [deps-cljs-content (deps-cljs (json/decode (slurp "package.json")))]
(println "[:flush-hook]" deps-cljs-content)
(spit deps-edn-path deps-cljs-content))
build-state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment