From 0b0f2aa39a06e77b1517f895a2c82946f684b568 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Fri, 12 Feb 2021 14:13:58 +0530 Subject: [PATCH] Format all Clojure files using zprint Signed-off-by: Joseph Nuthalapati --- git-pull-all.clj | 34 ++++++++++++++++------------------ lib.clj | 6 ++++-- update-babashka.clj | 19 ++++++++++++------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/git-pull-all.clj b/git-pull-all.clj index a8152d1..647db21 100755 --- a/git-pull-all.clj +++ b/git-pull-all.clj @@ -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 e4616af..8978c3a 100644 --- 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)) diff --git a/update-babashka.clj b/update-babashka.clj index 1681e4d..a449a7c 100755 --- a/update-babashka.clj +++ b/update-babashka.clj @@ -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) @@ -15,14 +16,17 @@ (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)] -- 2.43.0