-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
executable file
·58 lines (48 loc) · 939 Bytes
/
run.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
#!/bin/bash
print_usage() {
echo "Usage: $0 [NAME] [-b OPTION] [-i OPTION]"
}
if [ ! -n "$1" ]; then
print_usage
exit 1
fi
# $1 is sub $2 is all
contains_word() {
local word=$1
local text=$2
if echo "$text" | grep -qFe "$word"; then
echo "'$word' found in '$text'"
return 0
else
echo "'$word' not found in '$text'"
return 1
fi
}
run=$1
webpage=(
life
game
temp
)
for name in ${webpage[@]}
do
if contains_word "$name" "$run"; then
[ ! -n "$2" ] && pnpm $name && break
[ "$2" = "-b" ] && pnpm $name:build && break
break
fi
done
# cd $1
# 同时执行多个命令时的不同
# if [[ "$(uname)" == *"NT"* ]]; then
# echo "Windows"
# cd $1; pnpm dev
# else
# echo "Not Windows"
# if [[ "$(uname)" == *"Linux"* ]]; then
# echo "Linux"
# cd $1 && pnpm dev
# else
# echo "Not Linux"
# fi
# fi