-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
executable file
·65 lines (60 loc) · 1.63 KB
/
dev.sh
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
#!/bin/sh
script_dir="$(
cd "$(dirname "$0")"
pwd -P
)"
cd "$script_dir"
# shellcheck source=mainutil.sh
. mainutil.sh
# shellcheck source=shellutil.sh
. shellutil.sh
# shellcheck source=updateutil.sh
. updateutil.sh
# set -o xtrace
main() {
local command_help
command_help='docker - Develop inside a Docker container.
docker-format - Run format using a Docker container.
docker-update - Run update using a Docker container.
format - Run shfmt, prettier, and shellcheck.
git - Run git.
update - Check and update project dependencies.'
local commands
commands="$(main_extract_commands "$command_help")"
# shellcheck disable=SC2086
if [ -z "${1:-}" ]; then
main_exit_with_no_command_error "$command_help"
elif [ "$1" = "$(arg 0 $commands)" ]; then
shift
./git.sh docker "$@"
elif [ "$1" = "$(arg 1 $commands)" ]; then
./format.sh docker-format
elif [ "$1" = "$(arg 2 $commands)" ]; then
run_docker_update
elif [ "$1" = "$(arg 3 $commands)" ]; then
./format.sh format
elif [ "$1" = "$(arg 4 $commands)" ]; then
shift
./git.sh git "$@"
elif [ "$1" = "$(arg 5 $commands)" ]; then
update
else
main_exit_with_invalid_command_error "$1" "$command_help"
fi
}
run_docker_update() {
docker pull creemama/shellutil-dev:lts-alpine
docker run -it --rm \
--volume "$(pwd)":/tmp \
--workdir /tmp \
creemama/shellutil-dev:lts-alpine \
sh -c './dev.sh update'
}
update() {
apk_update_node_image_version format.sh
apk_update_node_image_version git.sh
# As a submodule, git status might not work in a Docker container mounted to this
# script_dir.
printf '%s%s\nRun git status.\n%s' "$(tbold)" "$(tyellow)" "$(treset)"
}
main "$@"