-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdev.sh
More file actions
64 lines (50 loc) · 1.14 KB
/
Copy pathdev.sh
File metadata and controls
64 lines (50 loc) · 1.14 KB
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
#! /usr/bin/env bash
PROJECT_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
build() {
npm run build
}
buildm() {
npm run build-mini
}
lint() {
npm run lint
}
changelog() {
npm run changelog
}
vtest() {
if [ -z "$1" ]; then
npm test
else
npm test src/"$1"
fi
}
vcoverage() {
if [ -z "$1" ]; then
npm run coverage
else
npm run coverage src/"$1"
fi
}
reload-dev() {
# shellcheck source=/dev/null
source "$PROJECT_ROOT_DIR"/dev.sh
}
_test_autotab() {
cur_dir=$(pwd)
_get_comp_words_by_ref -n : cur
if [ "${#COMP_WORDS[@]}" -eq 2 ]; then
cd "$PROJECT_ROOT_DIR"/src 2>/dev/null && _filedir 'test.ts'
for ((i = 0; i < ${#COMPREPLY[@]}; i++)); do
# 为目录时追加 /
# 如果已经在 src 目录则会由补全自动追加,不需要额外处理
if [ -d "${COMPREPLY[$i]}" ] && [ "$PROJECT_ROOT_DIR/src" != "${cur_dir}" ]; then
COMPREPLY["$i"]="${COMPREPLY[$i]}/"
else
COMPREPLY["$i"]="${COMPREPLY[$i]}"
fi
done
cd "${cur_dir}" || exit
fi
}
complete -o filenames -o nospace -o bashdefault -F _test_autotab vtest vcoverage