-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·83 lines (68 loc) · 1.61 KB
/
setup.sh
File metadata and controls
executable file
·83 lines (68 loc) · 1.61 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/zsh
zmodload zsh/mapfile
current_folder=`dirname $0:A`
repo_file=$current_folder/repos
repo_list=( "${(f)mapfile[$repo_file]}" )
workspace_dir=$current_folder/workspace
function doClean() {
echo "Removing ${workspace_dir}"
rm -rf $workspace_dir
}
function doClone() {
mkdir -p $workspace_dir
cd $workspace_dir
for repo in $repo_list; do
git clone git@github.com:${repo}.git
done
cd -
}
function doTag() {
for repo in $repo_list; do
repo_dir=`echo "$repo"|sed "s/.*\///"`
cd $workspace_dir/$repo_dir
gr tag add venus
cd -
done
}
function doNpmInstall() {
gr -t venus npm install --registry=http://registry.npmjs.org
}
function doNpmLink() {
for repo in $repo_list; do
repo_dir=`echo "$repo"|sed "s/.*\///"`
local_repo_dir=$workspace_dir/$repo_dir
module_dir=./node_modules/$repo_dir
cd $local_repo_dir
for inner_repo in $repo_list; do
inner_repo_dir=`echo "$inner_repo"|sed "s/.*\///"`
local_inner_repo_dir=$workspace_dir/$inner_repo_dir
module_dir=./node_modules/$inner_repo_dir
if [[ $inner_repo_dir != $repo_dir ]]; then
rm -rf $module_dir
ln -s $local_inner_repo_dir $module_dir
fi
done
cd -
done
}
function doAll() {
reply=n
vared -p "This will delete your local clones. You may lose work. Are you sure? (y/n) " reply
if [[ $reply =~ ^[Yy]$ ]]; then
doClean
doClone
doTag
doNpmInstall
doNpmLink
fi
}
function init() {
if [[ $1 == "install" ]]; then
doNpmInstall
elif [[ $1 == "link" ]]; then
doNpmLink
else
doAll
fi
}
init $@