Created
June 18, 2022 19:23
-
-
Save tylerw/83be543f2fb983033919fe0423a80ae8 to your computer and use it in GitHub Desktop.
Revisions
-
tylerw created this gist
Jun 18, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/usr/bin/env bb ;;; ; A babashka script to update all clojure -Ttools to the latest versions ; author: Tyler Wardhaugh ;;; (ns update-clj-tools (:require [babashka.fs :as fs] [babashka.process :refer [process]])) (defn install-latest "Install the latest version of tool by invoking clj(1) as a process." [tool] (let [base-cmd ["clj" "-Ttools" "install-latest" ":tool"]] @(process (conj base-cmd tool) {:out :inherit}))) (defn -main "Update tools in the directory passed in (defaulting to ~/.clojure/tools)" [args] (let [raw-path (or (first args) "~/.clojure/tools") path (-> raw-path fs/expand-home fs/canonicalize)] (doseq [tool (->> (fs/list-dir path "*.edn") (map (comp fs/strip-ext fs/file-name)))] (install-latest tool)))) (when (= *file* (System/getProperty "babashka.file")) (-main *command-line-args*))