-
Notifications
You must be signed in to change notification settings - Fork 18
/
install.sh
44 lines (35 loc) · 1.27 KB
/
install.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
#!/usr/bin/env bash
set -e # Fail if any command exits with nonzero status
if
[[ ! -d .git ]]
then
echo "I ain't no fool! You need to run this in the root of a git repository!"
exit 1
fi
command -v ruby >/dev/null 2>&1 || { echo >&2 "psdiff needs Ruby to run! Get yourself some Ruby, then try again!"; exit; }
if
[[ "$(gem list psd -i)" == "false" ]]
then
read -p "Damn, the 'psd' gem is not installed! Shall I fetch it now? (yes/no) " yn
case $yn in
[Yy]* ) echo -e "\nRunning 'gem install psd' (it might take ages, so please sit back!)"; gem install psd;;
* ) echo -e "\nThou shalt install the 'psd' gem before proceeding!"; exit 1;;
esac
echo # Empty line for the pretties
fi
mkdir -p ".git/hooks" # We need this if it doesn't exist!
cd ".git/hooks"
if
[[ -a pre-commit ]]
then
read -p "There's a 'pre-commit' hook in '.git/hooks' already. Should I overwrite? (yes/no) " yn
case $yn in
[Yy]* ) echo -e "\nOverwrite it be!";;
* ) echo -e "\nThis repo ain't big enough for both of us hooks!"; exit 1;;
esac
fi
# Get ze file
curl -sS "https://raw.githubusercontent.com/filp/psdiff/master/git/hooks/pre-commit" -o "pre-commit"
# Add execution bits to the user
chmod u+x "pre-commit"
echo -e "\nAll done! Go ahead and give me all your PSDs!"