Skip to content

Commit

Permalink
doo - call notifier from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bensu authored and stoyle committed Jul 23, 2016
1 parent 19b4339 commit 23a43d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion library/src/doo/notifier.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
(str/replace message "[" "\\["))

(defn- notify [title-postfix message]
{:pre [(string? title-postfix) (string? message)]}
(try
(shell/sh "terminal-notifier" "-message" (escape message) "-title" (str "doo - " (escape title-postfix)))
(catch Exception ex
Expand All @@ -28,7 +29,7 @@
(defn handle-notifications [out opts]
(when (:notify opts)
(let [old-status (notify-title @last-run)
new (reset! last-run (get-assertion-string @out))
new (reset! last-run (get-assertion-string out))
new-status (notify-title new)
changed (not= new-status old-status)]
(when (or changed (= :always (:notify opts)))
Expand Down
2 changes: 0 additions & 2 deletions library/src/doo/shell.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns doo.shell
"Rewrite of clojure.java.shell to have access to the output stream."
(:require [clojure.java.io :as io]
[doo.notifier :as notifier]
[doo.utils :as utils])
(:import (java.io StringWriter BufferedReader InputStreamReader File)
(java.nio.charset Charset)))
Expand Down Expand Up @@ -77,5 +76,4 @@
(let [proc (exec! cmd (:exec-dir opts))
{:keys [out err]} (capture-process! proc opts)
exit-code (.waitFor proc)]
(notifier/handle-notifications out opts)
{:exit exit-code :out @out :err @err})))
5 changes: 3 additions & 2 deletions plugin/src/leiningen/doo.clj
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ in project.clj.\n")
;; FIX: there is probably a bug regarding the incorrect use of builds
;; Important to add sources to the classpath
(run-local-project (add-sources project' source-paths)
'(require 'cljs.build.api 'doo.core 'doo.karma)
'(require 'cljs.build.api 'doo.core 'doo.karma 'doo.notifier)
`(let [compiler# (cljs.build.api/add-implicit-options ~compiler)]
(doseq [js-env# ~js-envs]
(doo.core/assert-compiler-opts js-env# compiler#))
Expand All @@ -239,7 +239,8 @@ in project.clj.\n")
(Thread/sleep 1000))
(doseq [js-env# non-karma-envs#]
(doo.core/print-envs js-env#)
(doo.core/run-script js-env# compiler# ~opts))
(let [r# (doo.core/run-script js-env# compiler# ~opts)]
(doo.notifier/handle-notifications (:out r#) ~opts)))
(when @karma-on?#
(apply doo.core/print-envs karma-envs#)
(doo.core/karma-run! ~opts))))))
Expand Down

0 comments on commit 23a43d5

Please sign in to comment.