-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
123 lines (101 loc) · 2.85 KB
/
justfile
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env -S just --justfile
# ^ A shebang isn't required, but allows a justfile to be executed
# like a script, with `./justfile test`, for example.
# ---------------------------------------------------------------------------- #
# just settings
# https://just.systems/man/en/chapter_26.html#settings
#
# bash with options. Reuse in recipes with #!{{ bash }}
bash := "/usr/bin/env bash -euo pipefail"
# Command used to invoke recipes and evaluate backticks.
# bash `-c` argument must be last.
set shell := ["bash", "-euo", "pipefail", "-c"]
# ---------------------------------------------------------------------------- #
# project variables
all-projects := `ls -d */`
# ---------------------------------------------------------------------------- #
default:
@just --choose
# lists recipes
list:
@just --list
# show var values
vars:
@just --evaluate
# -----[ Lint ]-----------------------------------------------------------------
# lint justfile
[no-exit-message]
_lint-just:
@just --unstable --fmt --check
# lint a single project
[no-exit-message]
_lint-one project:
@just {{ project }}/lint
# lints all projects
[no-exit-message]
_lint-all:
#!{{ bash }}
for project in {{ all-projects }}; do
echo Linting $project
just ${project}/lint
done
# lint justfile and one or more projects (default: all)
[no-exit-message]
lint project='all':
#!{{ bash }}
if [[ {{ project }} == 'all' ]]; then
just _lint-all
elif [[ {{ project }} == 'just' ]]; then
just _lint-just
else
just _lint-one {{ project }}
fi
# -----[ Format ]---------------------------------------------------------------
# format justfile
[no-exit-message]
_format-just:
@just --unstable --fmt
# format a single project
[no-exit-message]
_format-one project:
@just {{ project }}/format
# formats all projects
[no-exit-message]
_format-all:
#!{{ bash }}
for project in {{ all-projects }}; do
echo formating $project
just ${project}/format
done
# formats justfile or one or all projects (default: all)
[no-exit-message]
format project='all':
#!{{ bash }}
if [[ {{ project }} == 'all' ]]; then
just _format-all
elif [[ {{ project }} == 'just' ]]; then
just _format-just
else
just _format-one {{ project }}
fi
# -----[ Build ]----------------------------------------------------------------
# build a single project
[no-exit-message]
_build-one project:
@just {{ project }}/build
# build all projects
[no-exit-message]
_build-all:
#!{{ bash }}
for project in {{ all-projects }}; do
echo building $project
just ${project}/build
done
# build one or all projects (default: all)
build project='all':
#!{{ bash }}
if [[ {{ project }} == 'all' ]]; then
just _build-all
else
just _build-one {{ project }}
fi