X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/9da8be80d72b89328d70b47b71050251e32c470a..cd6a808b48af61f35ea08b9a4a4f225a9b490cd9:/update-babashka.clj diff --git a/update-babashka.clj b/update-babashka.clj index b14d0b9..afcaff1 100755 --- a/update-babashka.clj +++ b/update-babashka.clj @@ -1,9 +1,10 @@ #! /usr/bin/env bb -(require '[clojure.java.shell :refer [sh]] - '[cheshire.core :as json] +(require '[cheshire.core :as json] '[org.httpkit.client :as http] - '[babashka.fs :as fs]) + '[babashka.fs :as fs] + '[clojure.java.io :as io] + '[lib :refer [download-binary expand-home extract-file-from-zip]]) (defn babashka-latest-version [] @@ -35,9 +36,9 @@ (let [url (get-download-url version architecture)] (download-binary url output))) -(when (= *file* (System/getProperty "babashka.file")) - (let [architecture "linux-amd64" ;; TODO support multiple - ;; architectures +(defn update-babashka + [] + (let [architecture "linux-amd64" ;; TODO support other architectures zip-file "babashka.zip" destination (expand-home "~/bin/bb") version (babashka-latest-version)] @@ -49,3 +50,5 @@ (fs/set-posix-file-permissions destination "rwxr-xr-x") (io/delete-file zip-file) (println "Done!"))) + +(when (= *file* (System/getProperty "babashka.file")) (update-babashka))