-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathformat
executable file
·38 lines (31 loc) · 1005 Bytes
/
format
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
#!/bin/bash
# Disable "double quote to prevent globbing and word splitting"
# ${changed_files} is a list that needs to be split on words
# shellcheck disable=SC2086
set -e
if [[ -n "${IOW_BOUNDARY_TOOL_DEBUG}" ]]; then
set -x
fi
function usage() {
echo -n "Usage: $(basename "$0")
Run formatters on the project's code
"
}
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
if [ "${1:-}" = "--help" ]; then
usage
else
# Format JavaScript app
docker-compose \
run --rm --no-TTY --entrypoint yarn app \
prettier --loglevel warn --write src/
# Format Django app
# Get a list of changed ".py" files and trim "src/django"
changed_files=$(git status --porcelain | grep ".py" | awk -F'src/django/' '{print $2}' | xargs)
if [[ -n "${changed_files}" ]]; then
docker-compose \
run --rm --no-TTY --no-deps --entrypoint ./format.sh django \
${changed_files}
fi
fi
fi