Thanks @joshmiller. I wrote a babashka script to do the same thing:
#!/usr/bin/env bb
(ns preprocess
(:require [ :as io]
[clojure.string :as str]))
(defn preprocess-file [file-path]
(println file-path)
(let [content (slurp file-path)
preprocessed-content #_(str/replace content #"(\b[a-zA-Z_]\w*)!(\w*\b)" "$1_$2")
(str/replace content "!$" "_$")]
(spit file-path preprocessed-content)))
(defn preprocess-dir [dir-path]
(let [dir (io/file dir-path)]
(doseq [file (.listFiles dir)]
(if (.isFile file)
(let [file-name (.getName file)]
(when (str/ends-with? file-name ".js")
(preprocess-file (.getPath file))))
(preprocess-dir (.getPath file))))))
(defn -main [& args]
(println args)
(let [target-dir (ffirst args)]
(println target-dir)
(preprocess-dir target-dir)))
(when (first *command-line-args*)
(-main *command-line-args*))
this would be run after the compilation phase, as you have done. Your solution is simpler, though.I don’t want to take too much credit, I made ChatGPT tell me how to use find/sed
That’s what it’s for! Take the credit.👍