               end-parts (fw-util/path-parts (:relative-path source))]
           (when (= end-parts (take-last (count end-parts) res))
             (str (apply io/file (drop-last (count end-parts) res)))))))))
-
-(defn watch-dirs-from-build [{:keys [main] :as build-options}]
-  (let [watch-dirs (-> build-options meta :watch-dirs)
-        main-ns-dir (and main (watch-dir-from-ns (symbol main)))]
-    (not-empty (filter #(.exists (io/file %)) (cons main-ns-dir watch-dirs)))))
 
 (def default-main-repl-index-body
   (str

    (cond-> main-edn
      handler (assoc :ring-handler handler))))

(defn fetch-figwheel-main-edn [cfg]
  (try (read-string (slurp (io/file "figwheel-main.edn")))
       (catch Throwable t
         (throw (ex-info "Problem reading figwheel-main.edn" )))))

(defn- config-figwheel-main-edn [cfg]
  (if-not (.exists (io/file "figwheel-main.edn"))
    cfg
    (let [config-edn (or (::start-figwheel-options cfg)
                         (process-figwheel-main-edn
                          (fetch-figwheel-main-edn cfg)))]
      (-> cfg
          (update ::config merge config-edn)))))

(defn- config-merge-current-build-conf [{:keys [::extra-config ::build] :as cfg}]
  (update cfg

(defn -main [& args]
  (alter-var-root #'cli/default-commands cli/add-commands figwheel-commands)
  (try
    (let [args       (fix-simple-bool-args #{"-pc" "--pprint-config"} args)
          [pre post] (split-with (complement #{"-re" "--repl-env"}) args)
          args'      (if (empty? post) (concat ["-re" "figwheel"] args) args)
          args'      (if (empty? args) (concat args' ["-r"]) args')]
      (with-redefs [cljs.cli/default-compile default-compile]
        (apply cljs.main/-main args')))
    (catch Throwable e
