Created
March 20, 2019 20:07
-
-
Save arichiardi/521b449efb6e0c646b98ce1ed51bb905 to your computer and use it in GitHub Desktop.
Shadow-cljs cljs deps.edn hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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