This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-08-06
Channels
- # announcements (9)
- # babashka (22)
- # beginners (33)
- # cider (3)
- # clj-kondo (25)
- # clj-on-windows (1)
- # cljsrn (3)
- # clojure (38)
- # clojure-dev (10)
- # clojure-europe (17)
- # clojure-norway (45)
- # clojure-uk (3)
- # clojurescript (16)
- # code-reviews (20)
- # cursive (23)
- # data-science (18)
- # datomic (19)
- # fulcro (14)
- # funcool (5)
- # humbleui (34)
- # hyperfiddle (17)
- # jobs-discuss (3)
- # joyride (1)
- # malli (4)
- # off-topic (15)
- # polylith (10)
- # portland-or (2)
- # reitit (7)
- # releases (8)
- # shadow-cljs (11)
- # vim (30)
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.👍 1
I don’t want to take too much credit, I made ChatGPT tell me how to use find/sed