-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathbump-readme-version.clj
More file actions
executable file
·28 lines (23 loc) · 1.09 KB
/
Copy pathbump-readme-version.clj
File metadata and controls
executable file
·28 lines (23 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env clojure
(set! *warn-on-reflection* true)
(require '[clojure.java.io :as io]
'[clojure.string :as str])
(def new-version-string (first *command-line-args*))
(assert (string? new-version-string)
(str "Must pass version string as first argument to program"))
(defn update-readme-file [readme-file]
(assert (string? readme-file)
(str "Must pass readme file to program"))
(let [original-readme-file-lines (doall (-> readme-file io/reader line-seq))
version-string
(some (fn [^String line]
(when (.startsWith line "Latest stable release is")
(subs line (count "Latest stable release is ") (dec (count line)))))
original-readme-file-lines)
new-readme-file-lines
(map #(str/replace % version-string new-version-string)
original-readme-file-lines)]
(spit readme-file (str (str/join "\n" new-readme-file-lines) "\n"))))
(mapv update-readme-file (rest *command-line-args*))
(apply println (str "Updated to version: " new-version-string ":")
(rest *command-line-args*))