-
Notifications
You must be signed in to change notification settings - Fork 6.1k
/
Copy pathdocsCodeStyle.sh
executable file
·49 lines (41 loc) · 1.26 KB
/
docsCodeStyle.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
#!/usr/bin/env bash
set -e
## GLOBAL VARIABLES
REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
## FUNCTIONS
if [ "$CIRCLECI" ]
then
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput setaf 7)"; }
function printError { echo "$(tput setaf 1)$1$(tput setaf 7)"; }
else
function printTask { echo "$(tput bold)$(tput setaf 2)$1$(tput sgr0)"; }
function printError { echo "$(tput setaf 1)$1$(tput sgr0)"; }
fi
printTask "Checking docs examples style"
SOLTMPDIR=$(mktemp -d)
(
set -e
cd "$SOLTMPDIR"
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/
if npm -v >/dev/null 2>&1; then
if npm list -g | grep solhint >/dev/null 2>&1; then
echo "node is installed, setting up solhint"
cp "$REPO_ROOT"/test/.solhint.json "$SOLTMPDIR"/.solhint.json
cp "$REPO_ROOT"/test/.solhintignore "$SOLTMPDIR"/.solhintignore
for f in *.sol
do
echo "$f"
# Only report errors
solhint -f unix "$SOLTMPDIR/$f"
done
else
echo "node is installed, but not solhint"
exit 1
fi
else
echo "node not installed, skipping docs style checker"
exit 1
fi
)
rm -rf "$SOLTMPDIR"
echo "Done."