summaryrefslogtreecommitdiff
path: root/scripts/hooks/pre-push
blob: 84bdafd70ed50646e7b88eff2c9d773aceb521e9 (plain)
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
#!/usr/bin/env bash

cd "$(git rev-parse --show-toplevel 2>/dev/null)"
HOOK=$(basename "${BASH_SOURCE[0]}")
source "scripts/hooks/common.sh"

echo -n "Checking code formatting..."
RESULT=$(scripts/nitpick/format.js)
if [ ! -z "$RESULT" ]; then
    echo -e " \033[1;31mChanged\033[0m"
    echo -e -n "\033[1mDo you want to see the diff [y/N]?\033[0m "
    read < /dev/tty
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        echo "$RESULT"
        echo ""
    fi

    echo -e -n "\033[1mContinue to push? [Y/n]?\033[0m "
    read < /dev/tty
    if [[ $REPLY =~ ^[Nn]$ ]]; then
        exit 1
    fi
else
    echo -e " \033[32mOK\033[0m"
fi