generated from santi100a/npm-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
48 lines (44 loc) · 1.07 KB
/
pre-commit
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
#!/usr/bin/env bash
fail() {
echo $0
exit 1
}
WHITELIST=\
"santyrojasprieto9+github@gmail.com santyrojasprieto9@gmail.com 95766532+santi100a@users.noreply.github.com"
# Get the author's email address
AUTHOR_EMAIL=$(git log -1 --format="%ae")
echo $WHITELIST | grep -q "$AUTHOR_EMAIL"
# Check if the author's email is in the whitelist
if [ $? -ne 1 ]; then
echo "Author trusted: $AUTHOR_EMAIL, bypassing hook."
exit 0
fi
npm --version
if ! npm ls --global | grep "yarn" > /dev/null; then
npm i -g yarn@1.22.19
echo "Yarn ready!"
else
echo "Yarn found!"
fi
echo "📋 Validating package.json..."
yarn validate-package-json
if [ $? -ne 0 ]; then
fail "❌ Invalid package.json."
else
echo "✅ package.json is valid."
fi
echo "✨ Running Prettier..."
yarn prettify
if [ $? -ne 0 ]; then
fail "❌ Prettier error."
else
echo "✅ Prettified successfully."
fi
echo "📦 Updating ESM wrapper..."
yarn esm-wrapper
if [ $? -ne 0 ]; then
fail "❌ An error occured."
else
echo "✅ Wrapper updated successfully."
fi
echo "✅✅ Checks completed."