<commit_before>(ns om-css.output-css
  (:require [cljs.env :as env]
            [clojure.java.io :as io]
            [clojure.string :as string]))

(defn setup-io! []
     (let [opts (some-> env/*compiler*
                  deref
                  :options)
           default-fname "out.css"
           fname (or (:css-output-to opts)
                   (str (:output-dir opts) default-fname)
                   (string/join "/"
                     (-> (:output-to opts)
                       (string/split #"/")
                       butlast
                       vec
                       (conj default-fname))))]
       (add-watch om-css.core/css :watcher
         (fn [k atom old-state new-state]
           (with-open [out ^java.io.Writer (io/make-writer fname {})]
             (binding [*out* out]
               (println (string/join "\n" (vals new-state)))
               (println)))))))

(setup-io!)<commit_msg>use the cljs analyzer api instead of poking around env/*compiler*<commit_after>(ns om-css.output-css
  (:require [cljs.analyzer.api :as ana-api]
            [clojure.java.io :as io]
            [clojure.string :as string]))

(defn setup-io! []
  (let [{:keys [css-output-to output-dir output-to]} (ana-api/get-options)
        default-fname "out.css"
        fname (or css-output-to
                (str output-dir default-fname)
                (string/join "/"
                  (-> output-to
                    (string/split  #"/")
                    pop
                    (conj default-fname))))]
    (add-watch om-css.core/css :watcher
      (fn [k atom old-state new-state]
        (with-open [out ^java.io.Writer (io/make-writer fname {})]
          (binding [*out* out]
            (println (string/join "\n" (vals new-state)))
            (println)))))))

(setup-io!)
{'fraction_non_alphanumeric': 0.14941892639734367, 'fraction_numerical': 0.0, 'mean_word_length': 1.4399460188933872, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4987182', 'n_tokens_mistral': 571, 'n_tokens_neox': 546, 'n_words': 126}