-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.cljs
executable file
·51 lines (43 loc) · 1.41 KB
/
tasks.cljs
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
#!/usr/bin/env lumo
(ns core.tasks
(:require
[tasks.core :include-macros true :as t]))
(def fs (js/require "fs-extra"))
(def path (js/require "path"))
(defn with-temp-copy
"Copies file from source to dest, then calls the specified function.
Finally, dest file is returned to its initial state."
[source-path dest-path f]
(let [dest-els (.parse path dest-path)
backup-path (.join path
(.-dir dest-els)
(str (.-name dest-els)
(.-ext dest-els)
"_backup"))]
(try
(println "copy" dest-path "to" backup-path)
(.copySync fs dest-path backup-path)
(println "copy" source-path "to" dest-path)
(.copySync fs source-path dest-path)
(f)
(finally
(println "recover" dest-path "from" backup-path)
(.copySync fs backup-path dest-path)
(println "remove temp file" backup-path)
(.removeSync fs backup-path)))))
(defn ^:task api
"Compile API reference into site folder."
[]
(t/run "lein" "codox"))
(defn ^:task mkdocs
"Only build site pages using MkDocs."
[]
; use project's readme file for rendering the index page
(with-temp-copy "README.md" (.join path "docs" "index.md")
#(t/run "mkdocs" "build" "--clean")))
(defn ^:task site
"Build project site (including API docs)."
[]
(mkdocs)
(api))
(t/cli)