-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
executable file
·65 lines (46 loc) · 1.44 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
#!/usr/bin/env -S just -f
GO := "go"
MAIN_BIN := "bin/main"
SRC_PATHS := ". ./internal/..."
# General-purpose arguments to pass to a command. May be overridden at invocation.
# Example: just ARGS='-foo=bar -v' <recipe_name>
ARGS := ""
# list available recipes
default:
@{{ justfile() }} --list --unsorted
# compile a binary for package main
build: _bin_dir
@{{ GO }} build -o {{ MAIN_BIN }} {{ invocation_directory() }}
alias b := build
# execute the built binary
@run +ARGS='help':
{{ MAIN_BIN }} {{ ARGS }}
alias r := run
# build a new binary, run it
buildrun +ARGS='help': build (run ARGS)
alias br := buildrun
# get module dependencies, tidy them up, vendor them
mod:
{{ GO }} mod tidy
{{ GO }} mod vendor
# examine source code for suspicious constructs
vet ARGS='':
{{ GO }} vet {{ ARGS }} {{ SRC_PATHS }}
# run tests (override variable value ARGS to use test flags)
test PKG_PATH='./...':
{{ GO }} test {{ PKG_PATH }} {{ ARGS }}
_bin_dir:
@mkdir -pv {{ parent_directory(MAIN_BIN) }}
# Recipes for shell script maintenance rely on
# * shellcheck: https://github.com/koalaman/shellcheck
# * shfmt: https://github.com/mvdan/sh
SCRIPTS := `git ls-files | grep '\.sh$'`
# run shellcheck on scripts
lint-scripts:
shellcheck {{ SCRIPTS }}
# run shfmt on shell scripts
fmt-scripts:
shfmt -ci -d -s -sr {{ SCRIPTS }}
# run shfmt on shell scripts and overwrite files
fmtw-scripts:
shfmt -ci -d -s -sr -w {{ SCRIPTS }}