-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.janet
44 lines (38 loc) · 1.03 KB
/
project.janet
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
(declare-project
:name "format"
:description "janet string formatting")
(declare-native
:name "int-ext"
:source ["int-ext/int-ext.c"])
(declare-native
:name "dragonbox"
:cppflags ["-std=c++17"]
:source ["dragonbox/dragonbox-janet.cpp"])
(declare-source :source "format")
(defn format-recursive
[path]
(case (os/stat path :mode)
:file
(try
(when (string/has-suffix? ".janet" path)
(prinf "formatting: %s..." (string/replace (os/cwd) "" path))
(eval ['spork/fmt/format-file path])
(print "OK"))
([e]
(printf "ERROR %s" e)))
:directory
(let [filenames @[]]
(try
(os/dir path filenames)
([e]
(printf "WARN: failed to list directory %s: %s" path e)
(break)))
(loop [filename :in filenames]
(format-recursive (string path "/" filename))))))
(task "format" []
(try
(do
(import* "spork")
(format-recursive (os/cwd)))
([e]
(printf "failed to import spork/fmt: %q" e))))