-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only add cljx as a runtime dependency when running a REPL, fixes gh-47
- Loading branch information
Showing
1 changed file
with
22 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
(ns cljx.plugin | ||
(:require [clojure.java.io :as io])) | ||
(:require [robert.hooke :as hooke] | ||
leiningen.repl | ||
[clojure.java.io :as io])) | ||
|
||
(def ^:private cljx-version | ||
(-> (io/resource "META-INF/leiningen/com.keminglabs/cljx/project.clj") | ||
slurp | ||
read-string | ||
(nth 2))) | ||
(def cljx-coordinates | ||
(-> (or (io/resource "META-INF/leiningen/com.keminglabs/cljx/project.clj") | ||
(io/resource "META-INF/leiningen/org.clojars.cemerick/cljx/project.clj")) | ||
slurp | ||
read-string | ||
((fn [[_ artifact version]] [artifact version])))) | ||
|
||
(assert (string? cljx-version) | ||
(str "Something went wrong, version of cljx is not a string: " | ||
cljx-version)) | ||
(assert (and (symbol? (first cljx-coordinates)) | ||
(string? (second cljx-coordinates))) | ||
(str "Something went wrong, cljx coordinates are invalid: " | ||
cljx-coordinates)) | ||
|
||
(defn middleware | ||
[project] | ||
(-> project | ||
(update-in [:dependencies] | ||
(fnil into []) | ||
[['com.keminglabs/cljx cljx-version]]) | ||
(if (or (-> project :cljx :disable-repl-integration) | ||
(not (-> project meta :included-profiles set (contains? :repl)))) | ||
project | ||
(-> project | ||
(update-in [:repl-options :nrepl-middleware] | ||
(fnil into []) | ||
'[cljx.repl-middleware/wrap-cljx cemerick.piggieback/wrap-cljs-repl]))) | ||
(fnil into []) | ||
'[cljx.repl-middleware/wrap-cljx cemerick.piggieback/wrap-cljs-repl]) | ||
(update-in [:dependencies] | ||
(fnil conj []) | ||
cljx-coordinates)))) |