(local http (require :socket.http))
(local luzip (require :luzip))

(local fennel (require :fennel))
(fn pp [x] (print (fennel.view x)))

(local path "http://github.com/alexjgriffith/update-lovejs/releases/download/115-beta1.1/love115-compat-single-beta1.zip")

(local lovejs
       ;; Try to open cached version of love.js
       (case (pcall (fn [] (with-open [f (io.open :love.js)] (f:read :*all))))
         ;; if sucsesfull return the cached version
         (true lovejs) lovejs
         ;; if not download lovejs from github and unzip it
         false (let [(body _stats _headers) (http.request path)
                     ;; you can unzip a string directly
                     unzipped (luzip.unzip-to-strings body)
                     lovejs (. unzipped :love.js)]
                 ;; you can cache a file for later use
                 (with-open [f (io.open :love.js :w)] (f:write lovejs))
                 ;; check out the files in love115-compat-single-beta1.zip
                 (pp (icollect [key _ (pairs unzipped)] key))
                 ;; check out the size of love.js
                 (pp (# (. unzipped :love.js)))                 
                 lovejs)))

;; do anything you want with lovejs

Generated by alexjgriffith using scpaste at Mon Oct 6 20:41:09 2025. EDT. (original)