-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.joke
executable file
·52 lines (42 loc) · 1.34 KB
/
build.joke
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env joker
(ns script
(:require [joker.os :as os]
[joker.string :as st]))
(defn run
[& cmd]
(let [{:keys [out err]} (apply os/sh cmd)]
(println err)
(println out)))
(defn remove-first-line
[s]
(st/join "\n" (rest (st/split s "\n"))))
(defn remove-last-line
[s]
(st/join "\n" (drop-last (st/split s "\n"))))
(defn remove-es_2019
"Removes some code that is invalid GS and is otherwise seemingly unnecessary."
[s]
(st/replace
s
"
a(\"es_2019\", function() {
return b('let r;try{r\\x3d\"
\"}catch{};r');
});"
""))
(def frontmatter
"var global = {}; var process = {\"argv\": [\"one\", \"two\"]};")
(run "rm" "Code.js")
; (run "lein" "cljsbuild" "once")
(run "npx" "shadow-cljs" "release" "autojournal-for-gas")
; TODO do this:
; https://clojurians.slack.com/archives/C6N245JGG/p1652646542137479 instead of
; this hacky file manipulation
(let [code (-> (slurp "Code.js")
(remove-es_2019)
(remove-first-line) ; Remove the #! line
(remove-first-line) ; Remove the `(function(){` line
(remove-last-line) ; Remove a newline
(remove-last-line)) ; Remove the `})();` line
entrypoints (slurp "src/autojournal/entry_points.js")]
(spit "Code.js" (str frontmatter "\n" code "\n" entrypoints)))
(run "clasp" "push")