-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclonerepo.sh
executable file
·72 lines (63 loc) · 963 Bytes
/
clonerepo.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
66
67
68
69
#!/bin/bash
help () {
echo "
ERROR: Invalid option.
Accepted options:
-r [repo name]
-o [organization] (optional)
Example:
clonerepo.sh -r truffle -o trufflesuite
"
}
text=$1
IFS='/'
read -a strarr <<< "$text"
for val in "${strarr[@]}";
do
if [[ "$ORG" == "" ]]; then
ORG=$val
else
REPO=$val
fi
done
if [[ "$REPO" == "" || "$ORG" == "" ]]; then
ORG=sullof
while getopts "r:o:" opt; do
case $opt in
r)
REPO=$OPTARG
;;
o)
ORG=$OPTARG
;;
\?)
help
exit 1
;;
esac
done
fi
if [[ "$REPO" == "" ]]; then
help
exit 1
fi
(
cd ~/Projects/Repos
git clone [email protected]:$ORG/$REPO.git
cd $REPO
if [[ -f "package.json" ]]; then
if [[ -f "yarn.lock" ]]; then
yarn
elif [[ -f "pnpm-lock.yaml" ]]; then
pnpm i
else
npm i
fi
fi
CB=$(which clipboard)
if [[ "$CB" == "" ]]; then
echo "~/Projects/Repos/$REPO" | pbcopy
else
echo "~/Projects/Repos/$REPO" | clipboard
fi
)