           ;; first build shouldn't send notifications
           ((if (= cljs-build-fn figwheel-build)
              (-> cljs-build
+                 notify-command-hook
                  catch-print-hook
                  injection/hook
                  figwheel-start-and-end-messages)

                 *err* log-writer]
         (cljs-build-fn
          (assoc cljs-autobuild
            :changed-files (map str files))))
       (when-let [notify-command (-> cljs-autobuild :build-config :notify-command)]
         (println (:out (apply sh notify-command))))))))

(defrecord CLJSAutobuild [build-config figwheel-server]
  component/Lifecycle

                      "\" in " (elapsed started-at) "." reset-color))
        (flush)))))


(defn handle-notify-command [build-state s]
  (when-let [notify-command (-> build-state :build-config :notify-command)]
    (apply sh (concat notify-command [s]))))

(defn notify-command-hook [build-fn]
  (fn [build-state]
    (try
      (build-fn build-state)
      (handle-notify-command build-state (str "Successfully compiled ClojureScript build: "
                                              (name (-> build-state :build-config :id))))
      (catch Throwable e
        (handle-notify-command build-state (str "Failed compiling ClojureScript build: "
                                                (name (-> build-state :build-config :id))))
        (throw e)))))

(def figwheel-build
  (-> cljs-build
      injection/hook
      notify-command-hook
      notifications/hook
      clj-reloading/hook
      javascript-reloading/hook
