   (:require [cljs.reader :as reader]
             ["readline" :as rl]
             ["net" :as node-net]
+            ["fs" :as fs]
             [shadow.cljs.npm.util :as util]
             [clojure.string :as str]))
 

        (js/process.stdin.removeListener "close" stop!)
        ))))

(defn run [project-root config server-pid opts args]
  (let [cli-repl
        (-> (util/slurp server-pid)
            (js/parseInt 10))]

    (if-not (pos-int? cli-repl)
      (prn [:no-socket-repl-port server-pid cli-repl])
      (let [socket (node-net/connect cli-repl "localhost")]
        (if (get-in opts [:options :stdin])
          (socket-pipe socket args)
          (repl-client socket args)
          )))))


          (.end socket)
          (println))]

    (println "shadow-cljs - connected to server")

    ;; FIXME: this is an ugly hack that will be removed soon
    ;; its just a quick way to interact with the server without a proper API protocol
    (write (str "(shadow.cljs.devtools.cli/from-remote " (pr-str exit-token) " " (pr-str error-token) " " (pr-str (into [] args)) ")\n"))

    (.on rl "line"
      (fn [line]
        (write (str line "\n"))))

    ;; CTRL+D closes the rl
    (.on rl "close"
      (fn []
        (stop!)))

    (.on socket "data"
      (fn [data]
