Created
June 18, 2022 19:23
-
-
Save tylerw/83be543f2fb983033919fe0423a80ae8 to your computer and use it in GitHub Desktop.
Quick-and-dirty script to update all Clojure -Ttools
This file contains 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 characters
#!/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*)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of Clojure CLI 1.11.1.1149 this functionality is builtin:
clj -Ttools install-latest