Skip to content

Commit 3b254f7

Browse files
authored
Merge pull request popcorn-official#3019 from wiryhatbox/update-script
2 parents c9bfece + 24a70a8 commit 3b254f7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

make_popcorn.sh

+14-7
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ else
2424
fi
2525

2626
clone_command() {
27-
if git clone "$clone_url" "$dir"; then
27+
if git clone -- "$clone_url" "$dir"; then
2828
echo "Cloned Popcorn Time successfully"
2929
else
3030
echo "Popcorn Time encountered an error and could not be cloned"
3131
exit 2
3232
fi
3333
}
3434

35-
if [ -e ".git/config" ]; then
36-
dat="$(grep url .git/config)"
35+
git_dir="$(git rev-parse --git-dir 2>/dev/null)" || git_dir=".git"
36+
if [ -e "$git_dir"/config ]; then
37+
dat="$(grep -- url "$git_dir"/config)"
3738
case "$dat" in *popcorn*)
3839
echo "You appear to be inside of a Popcorn Time repository already, not cloning"
3940
clone_repo="False"
41+
cd -- "$(dirname "$git_dir")" # otherwise yarn build might fail
4042
;;
4143
*)
4244
try="True"
@@ -67,7 +69,7 @@ if [ -e ".git/config" ]; then
6769
fi
6870
if [ "$clone_repo" = "True" ]; then
6971
echo "Cloning Popcorn Time"
70-
read -r -p "Where do you wish to clone Popcorn Time to? [popcorn] " dir
72+
read -p "Where do you wish to clone Popcorn Time to? [popcorn] " dir
7173
if [ -z "$dir" ]; then
7274
dir='popcorn'
7375
elif [ "$dir" = "/" ]; then
@@ -98,7 +100,10 @@ if [ "$clone_repo" = "True" ]; then
98100
echo "Removing old directory"
99101
if [ "$dir" != "." ] || [ "$dir" != "$PWD" ]; then
100102
echo "Cleaning up from inside the destination directory"
101-
rm -rf "$dir"
103+
if ! rm -rf -- "$dir"; then
104+
echo "Cannot delete the directory"
105+
exit 4
106+
fi
102107
fi
103108
clone_command
104109
else
@@ -110,7 +115,9 @@ fi
110115
if [ -z "$dir" ]; then
111116
dir="."
112117
fi
113-
cd "$dir"
118+
119+
cd -- "$dir"
120+
114121
echo "Switched to $PWD"
115122

116123
if [ "$rd_dep" = "yes" ]; then
@@ -124,7 +131,7 @@ fi
124131

125132
if yarn build; then
126133
echo "Popcorn Time built successfully!"
127-
if [[ "$(uname -s)" != *"NT"* ]]; then # if not windows
134+
if [[ ! "$(uname -s)" =~ "NT" ]]; then # if not windows
128135
./Create-Desktop-Entry
129136
fi
130137
echo "Run 'yarn start' to launch the app or run Popcorn-Time from the ./build folder..."

0 commit comments

Comments
 (0)