-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclonefork.sh
executable file
·73 lines (66 loc) · 1.08 KB
/
clonefork.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
70
71
72
73
#!/bin/bash
help () {
echo "
ERROR: Invalid option.
Accepted options:
-r [repo name]
-u [upstream user name] (optional)
Example:
clonefork.sh -r truffle -u trufflesuite
clonefork.sh trufflesuite/truffle
"
}
text=$1
IFS='/'
read -a strarr <<< "$text"
for val in "${strarr[@]}";
do
if [[ "$UPSTREAM" == "" ]]; then
UPSTREAM=$val
else
REPO=$val
fi
done
if [[ "$REPO" == "" || "$UPSTREAM" == "" ]]; then
while getopts "r:u:" opt; do
case $opt in
r)
REPO=$OPTARG
;;
u)
UPSTREAM=$OPTARG
;;
\?)
help
exit 1
;;
esac
done
fi
if [[ "$REPO" == "" ]]; then
help
exit 1
fi
(
cd ~/Projects/Forks
git clone [email protected]:sullof/$REPO.git
cd $REPO
if [[ "$UPSTREAM" != "" ]]; then
mergeUpstream.sh $UPSTREAM
fi
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/Forks/$REPO" | pbcopy
else
echo "~/Projects/Forks/$REPO" | clipboard
fi
)