Remove interactive and test! tasks.
This commit is contained in:
parent
7d993c2c09
commit
c7583008eb
4 changed files with 5 additions and 98 deletions
|
@ -1,7 +1,7 @@
|
|||
(ns leiningen.compile
|
||||
"Compile Clojure source into .class files."
|
||||
(:use [leiningen.deps :only [deps find-deps-files]]
|
||||
[leiningen.core :only [defdeprecated user-settings *interactive?*]]
|
||||
[leiningen.core :only [defdeprecated user-settings]]
|
||||
[leiningen.javac :only [javac]]
|
||||
[leiningen.classpath :only [get-classpath-string]]
|
||||
[clojure.java.io :only [file resource reader copy]]
|
||||
|
@ -122,8 +122,7 @@
|
|||
(finally
|
||||
(when (and ~(:shutdown-agents project false)
|
||||
(not= "1.5" (System/getProperty
|
||||
"java.specification.version"))
|
||||
~(not *interactive?*))
|
||||
"java.specification.version")))
|
||||
(shutdown-agents)))))]
|
||||
;; work around java's command line handling on windows
|
||||
;; http://bit.ly/9c6biv This isn't perfect, but works for what's
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
(ns leiningen.interactive
|
||||
"Enter interactive task shell."
|
||||
(:require [clojure.string :as string]
|
||||
[clojure.java.io :as io])
|
||||
(:use [leiningen.core :only [apply-task exit *interactive?*]]
|
||||
[leiningen.test :only [*exit-after-tests*]]
|
||||
[leiningen.repl :only [repl-server repl-socket-on
|
||||
copy-out-loop poll-repl-connection]]
|
||||
[leiningen.compile :only [eval-in-project]]))
|
||||
|
||||
(def welcome "Welcome to Leiningen. Type help for a list of commands.")
|
||||
|
||||
(def prompt "lein> ")
|
||||
|
||||
(defn not-found [& _]
|
||||
(println "That's not a task. Use help to list all tasks."))
|
||||
|
||||
(defn- eval-client-loop [reader buffer socket]
|
||||
(let [len (.read reader buffer)]
|
||||
(when-not (neg? len)
|
||||
(.write *out* buffer 0 len)
|
||||
(.flush *out*)
|
||||
(when-not (.isClosed socket)
|
||||
(Thread/sleep 100)
|
||||
(recur reader buffer socket)))))
|
||||
|
||||
(defn eval-in-repl [connect project form & [_ _ init]]
|
||||
(let [[reader writer socket] (connect)]
|
||||
(.write writer (str "(do " (pr-str init)
|
||||
(pr-str form) "\n" '
|
||||
(.close *in*) ")\n"))
|
||||
(.flush writer)
|
||||
(try (eval-client-loop reader (make-array Character/TYPE 1000) socket)
|
||||
0
|
||||
(catch Exception e
|
||||
(.printStackTrace e) 1)
|
||||
(finally
|
||||
(.close reader)
|
||||
(.close writer)))))
|
||||
|
||||
(defn print-prompt []
|
||||
(print prompt)
|
||||
(flush))
|
||||
|
||||
(defn task-repl [project]
|
||||
(print-prompt)
|
||||
(loop [input (.readLine *in*)]
|
||||
(when (and input (not= input "exit"))
|
||||
(let [[task-name & args] (string/split input #"\s")]
|
||||
;; TODO: don't start a second repl server for repl task
|
||||
(try (apply-task task-name project args not-found)
|
||||
;; TODO: not sure why, but repl seems to put an extra EOF on *in*
|
||||
(when (= "repl" task-name)
|
||||
(.read *in*))
|
||||
(catch Exception e
|
||||
(println (.getMessage e))))
|
||||
(print-prompt)
|
||||
(recur (.readLine *in*))))))
|
||||
|
||||
(defn interactive
|
||||
"Enter an interactive task shell. Aliased to \"int\"."
|
||||
[project]
|
||||
(.delete (io/file "/tmp/bugger-all"))
|
||||
(let [[port host] (repl-socket-on project)]
|
||||
(println welcome)
|
||||
(future
|
||||
(binding [*interactive?* true]
|
||||
(eval-in-project project (repl-server project host port
|
||||
:prompt '(fn [])
|
||||
:caught '(fn [t]
|
||||
(println (.getMessage t))
|
||||
(.printStackTrace t)
|
||||
(.close *in*))))))
|
||||
(let [connect #(poll-repl-connection port 0 vector)]
|
||||
(binding [eval-in-project (partial eval-in-repl connect)
|
||||
*exit-after-tests* false
|
||||
*interactive?* true
|
||||
exit (fn exit [& _] (prn))]
|
||||
(task-repl project)))
|
||||
(exit)))
|
|
@ -1,7 +1,7 @@
|
|||
(ns leiningen.repl
|
||||
"Start a repl session either with the current project or standalone."
|
||||
(:require [clojure.main])
|
||||
(:use [leiningen.core :only [exit user-settings *interactive?*]]
|
||||
(:use [leiningen.core :only [exit user-settings]]
|
||||
[leiningen.compile :only [eval-in-project]]
|
||||
[leiningen.deps :only [find-deps-files deps]]
|
||||
[leiningen.trampoline :only [*trampoline?*]]
|
||||
|
@ -76,9 +76,8 @@
|
|||
.start)
|
||||
(if ~*trampoline?*
|
||||
(clojure.main/repl ~@options)
|
||||
(do (when-not ~*interactive?*
|
||||
(println "REPL started; server listening on"
|
||||
~host "port" ~port))
|
||||
(do (println "REPL started; server listening on"
|
||||
~host "port" ~port)
|
||||
;; block to avoid shutdown-agents
|
||||
@(promise))))))
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
(ns leiningen.test!
|
||||
"Run the project's tests after cleaning and fetching dependencies."
|
||||
(:refer-clojure :exclude [test])
|
||||
(:use [leiningen.clean :only [clean]]
|
||||
[leiningen.deps :only [deps]]
|
||||
[leiningen.test :only [test]]))
|
||||
|
||||
(defn test!
|
||||
"Run a project's tests after cleaning and fetching dependencies."
|
||||
[project & nses]
|
||||
(apply test (doto project clean deps) nses))
|
Loading…
Reference in a new issue