-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_lefthook.sh
executable file
·61 lines (42 loc) · 748 Bytes
/
setup_lefthook.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
#!/bin/bash
function check_permission {
if [ "$(id -u)" -ne 0 ]
then
echo "This script must be run by root."
exit 1
fi
}
function configure_lefthook {
cd "$(dirname "$0")" || exit
npx lefthook add pre-commit
if [ "${exit_code}" -gt 0 ]
then
echo "Unable to configure Lefthook."
exit 1
fi
}
function install_lefthook {
npm install @arkweid/lefthook@0.7.7 --save-dev
local exit_code=$?
if [ "${exit_code}" -gt 0 ]
then
echo "Unable to install Lefthook."
exit 1
fi
}
function install_npm {
apt install npm
local exit_code=$?
if [ "${exit_code}" -gt 0 ]
then
echo "Unable to install NPM."
exit 1
fi
}
function main {
check_permission
install_npm
install_lefthook
configure_lefthook
}
main "${@}"