]> njoseph.me Git - babashka-scripts.git/blame - lib.clj
Format all Clojure files using zprint
[babashka-scripts.git] / lib.clj
CommitLineData
1770a260 1; Common utility functions used by scripts
f1d839f5
JN
2
3(import '[java.nio.file Files FileSystems CopyOption StandardCopyOption])
4
5(defn extract-file-from-zip
6 [zip-file-name source destination]
7 (let [zip-file (io/file zip-file-name)
8 src (io/file source)
9 dest (io/file destination)
10 fs (FileSystems/newFileSystem (.toPath zip-file) nil)
11 file-in-zip (.getPath fs source (into-array String []))]
0b0f2aa3
JN
12 (Files/copy file-in-zip
13 (.toPath dest)
f1d839f5
JN
14 (into-array CopyOption [StandardCopyOption/REPLACE_EXISTING]))))
15
0b0f2aa3
JN
16(defn expand-home
17 [s]
f1d839f5
JN
18 (if (.startsWith s "~")
19 (clojure.string/replace-first s "~" (System/getProperty "user.home"))
20 s))