]> njoseph.me Git - babashka-scripts.git/blobdiff - lib.clj
Integrate clj-kondo. Add .gitignore
[babashka-scripts.git] / lib.clj
diff --git a/lib.clj b/lib.clj
index e4616afe687eb257edbe3112b5fc749eb9f69562..70fef53590648bb52015649d4ad872c4bc326737 100644 (file)
--- a/lib.clj
+++ b/lib.clj
@@ -2,6 +2,15 @@
 
 (import '[java.nio.file Files FileSystems CopyOption StandardCopyOption])
 
+(require '[babashka.process :as p] '[org.httpkit.client :as http])
+
+(defn run-cmd
+  [command]
+  (->> command
+       p/process
+       :out
+       slurp))
+
 (defn extract-file-from-zip
   [zip-file-name source destination]
   (let [zip-file (io/file zip-file-name)
         dest (io/file destination)
         fs (FileSystems/newFileSystem (.toPath zip-file) nil)
         file-in-zip (.getPath fs source (into-array String []))]
-    (Files/copy file-in-zip (.toPath dest)
+    (Files/copy file-in-zip
+                (.toPath dest)
                 (into-array CopyOption [StandardCopyOption/REPLACE_EXISTING]))))
 
-(defn expand-home [s]
+(defn expand-home
+  [s]
   (if (.startsWith s "~")
     (clojure.string/replace-first s "~" (System/getProperty "user.home"))
     s))
+
+(defn download-binary
+  [url destination]
+  (io/copy (:body @(http/get url)) (io/file destination)))