diff --git a/src/refactor_nrepl/core.clj b/src/refactor_nrepl/core.clj index 386b8666..6e41a00e 100644 --- a/src/refactor_nrepl/core.clj +++ b/src/refactor_nrepl/core.clj @@ -9,6 +9,17 @@ [refactor-nrepl.s-expressions :as sexp]) (:import [java.io File FileReader PushbackReader StringReader])) +(defn version [] + (let [v (-> (or (io/resource "refactor-nrepl/refactor-nrepl/project.clj") + "project.clj") + slurp + read-string + (nth 2))] + (assert (string? v) + (str "Something went wrong, version is not a string: " + v)) + v)) + (defn ns-from-string "Retrieve the symbol naming the ns from file-content." [file-content] diff --git a/src/refactor_nrepl/middleware.clj b/src/refactor_nrepl/middleware.clj index 8f3ef29a..e45e2d8b 100644 --- a/src/refactor_nrepl/middleware.clj +++ b/src/refactor_nrepl/middleware.clj @@ -8,6 +8,7 @@ [refactor-nrepl.artifacts :refer [artifact-list artifact-versions hotload-dependency]] [refactor-nrepl.config :as config] + [refactor-nrepl.core :as core] [refactor-nrepl.extract-definition :refer [extract-definition]] [refactor-nrepl.find.find-locals :refer [find-used-locals]] [refactor-nrepl.find.find-symbol :refer [find-symbol]] @@ -15,7 +16,6 @@ [refactor-nrepl.ns.libspecs :refer [namespace-aliases]] [refactor-nrepl.ns.pprint :refer [pprint-ns]] [refactor-nrepl.ns.resolve-missing :refer [resolve-missing]] - [refactor-nrepl.plugin :as plugin] [refactor-nrepl.rename-file-or-dir :refer [rename-file-or-dir]] [refactor-nrepl.stubs-for-interface :refer [stubs-for-interface]])) @@ -78,7 +78,7 @@ (reply transport msg :used-locals (find-used-locals msg))) (defn- version-reply [{:keys [transport] :as msg}] - (reply transport msg :status :done :version (plugin/version))) + (reply transport msg :status :done :version (core/version))) (defn- warm-ast-cache-reply [{:keys [transport] :as msg}] (reply transport msg :status :done diff --git a/src/refactor_nrepl/plugin.clj b/src/refactor_nrepl/plugin.clj index be70e820..f4692761 100644 --- a/src/refactor_nrepl/plugin.clj +++ b/src/refactor_nrepl/plugin.clj @@ -1,22 +1,12 @@ (ns refactor-nrepl.plugin - (:require [clojure.java.io :as io] - [leiningen.core.main :as lein])) + (:require + [refactor-nrepl.core :as core] + [leiningen.core.main :as lein])) (def ^:private external-dependencies ;; For whatever reason it didn't work to look for cider-nrepl here. {'org.clojure/clojure "1.7.0"}) -(defn version [] - (let [v (-> (or (io/resource "refactor-nrepl/refactor-nrepl/project.clj") - "project.clj") - slurp - read-string - (nth 2))] - (assert (string? v) - (str "Something went wrong, version is not a string: " - v)) - v)) - (defn- version-ok? [dependencies artifact version-string] (or (->> dependencies @@ -38,7 +28,7 @@ (-> project (update-in [:dependencies] (fnil into []) - [['refactor-nrepl (version)]]) + [['refactor-nrepl (core/version)]]) (update-in [:repl-options :nrepl-middleware] (fnil into []) '[refactor-nrepl.middleware/wrap-refactor])) diff --git a/test/refactor_nrepl/integration_tests.clj b/test/refactor_nrepl/integration_tests.clj index 588d8890..3d798f61 100644 --- a/test/refactor_nrepl/integration_tests.clj +++ b/test/refactor_nrepl/integration_tests.clj @@ -4,7 +4,7 @@ [clojure.tools.nrepl.server :as nrserver] [refactor-nrepl middleware [client :refer :all] - [plugin :as plugin]] + [core :as core]] [clojure.string :as str]) (:import java.io.File org.apache.commons.io.FileUtils)) @@ -235,5 +235,5 @@ :line 12 :column 6)))))) (deftest test-version - (is (= (str (plugin/version)) + (is (= (str (core/version)) (version :transport (connect :port 7777)))))