]> njoseph.me Git - babashka-scripts.git/commitdiff
Format all Clojure files using zprint
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 12 Feb 2021 08:43:58 +0000 (14:13 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 12 Feb 2021 08:43:58 +0000 (14:13 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
git-pull-all.clj
lib.clj
update-babashka.clj

index a8152d1fac3838ea73699a6c4880a3a18d9578e7..647db21fd52cd8f487bf332d06f3c14f4cb7e451 100755 (executable)
@@ -2,30 +2,28 @@
 
 ; Runs `git pull` on all the git repositories in a directory
 
-(require '[babashka.process :as p]
-         '[clojure.java.io :as io])
+(require '[babashka.process :as p] '[clojure.java.io :as io])
 
 (def default-root ".")
-  
-(defn list-dirs
-  [root]
-  (filter #(.isDirectory %) (.listFiles (io/file root))))
 
-(defn git-pull
-  [dir]
-  (p/process ["git" "-C" dir "pull" "--rebase"]))
+(defn list-dirs [root] (filter #(.isDirectory %) (.listFiles (io/file root))))
+
+(defn git-pull [dir] (p/process ["git" "-C" dir "pull" "--rebase"]))
 
 (when (= *file* (System/getProperty "babashka.file"))
-  (let [root  (get (into [] *command-line-args*) 0 default-root)
-        dirs  (list-dirs root)
+  (let [root (get (into [] *command-line-args*) 0 default-root)
+        dirs (list-dirs root)
         pulls (->> root
                    list-dirs
                    (map git-pull)
                    doall)
-        outputs (map #(->> % p/check :out slurp) pulls)]
-
-        ;; Print corresponding directory name when pulling
-        ;; Skip printing already up to date repos
-       (doseq [[dir out](filter #(not (.contains (second %) "is up to date."))
-                                (map vector dirs outputs))]
-         (println (str dir "\n" out)))))
+        outputs (map #(->> %
+                           p/check
+                           :out
+                           slurp)
+                  pulls)]
+    ;; Print corresponding directory name when pulling
+    ;; Skip printing already up to date repos
+    (doseq [[dir out] (filter #(not (.contains (second %) "is up to date."))
+                        (map vector dirs outputs))]
+      (println (str dir "\n" out)))))
diff --git a/lib.clj b/lib.clj
index e4616afe687eb257edbe3112b5fc749eb9f69562..8978c3a2acf466c281022da8d72caaaf16a1bc91 100644 (file)
--- a/lib.clj
+++ b/lib.clj
@@ -9,10 +9,12 @@
         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))
index 1681e4db7f712ec31436cd86e720005ebeb501af..a449a7c3a5db5bab9cafbaeae74e34b3d649aff0 100755 (executable)
@@ -5,7 +5,8 @@
          '[babashka.curl :as curl]
          '[babashka.fs :as fs])
 
-(defn babashka-latest-version []
+(defn babashka-latest-version
+  []
   (-> (curl/get "https://api.github.com/repos/babashka/babashka/tags")
       :body
       (json/parse-string true)
 
 (defn download-binary
   [url destination]
-  (io/copy
-   (:body (curl/get url {:as :stream}))
-   (io/file destination)))
+  (io/copy (:body (curl/get url {:as :stream})) (io/file destination)))
 
 (defn get-download-url
   [version architecture]
-  (str "https://github.com/babashka/babashka/releases/download/v" version "/babashka-"
-        version "-" architecture ".zip"))
+  (str "https://github.com/babashka/babashka/releases/download/v"
+       version
+       "/babashka-"
+       version
+       "-"
+       architecture
+       ".zip"))
 
 (defn check-latest
   [version]
@@ -37,7 +41,8 @@
     (download-binary url output)))
 
 (when (= *file* (System/getProperty "babashka.file"))
-  (let [architecture "linux-static-amd64"  ;; TODO support multiple architectures
+  (let [architecture "linux-static-amd64"  ;; TODO support multiple
+                                           ;; architectures
         zip-file "babashka.zip"
         destination (expand-home "~/bin/bb")
         version (babashka-latest-version)]