-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathforge-inspect.bash
More file actions
executable file
·52 lines (41 loc) · 1.34 KB
/
forge-inspect.bash
File metadata and controls
executable file
·52 lines (41 loc) · 1.34 KB
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
#!/bin/bash
# usage: ./test/util/forge-inspect.bash <outputDir> <inspectType>
contracts=$(./scripts/template/print-contracts.bash)
if [[ $? != "0" ]]; then
echo "Failed to get contracts"
exit 1
fi
outputDir=$1
inspectType=$2
CHANGED=0
for contractName in $contracts; do
echo "Checking for $inspectType changes in $contractName"
# if the file doesn't exist, create it
if [ ! -f "$outputDir/$contractName" ]; then
forge inspect "$contractName" "$inspectType" --pretty > "$outputDir/$contractName"
CHANGED=1
# if the file does exist, compare it
else
mv "$outputDir/$contractName" "$outputDir/$contractName-old"
forge inspect "$contractName" "$inspectType" --pretty > "$outputDir/$contractName"
diff "$outputDir/$contractName-old" "$outputDir/$contractName"
if [[ $? != "0" ]]; then
CHANGED=1
fi
fi
done
rm -f "$outputDir"/*-old
# Remove files for contracts that no longer exist
for existingFile in "$outputDir"/*; do
filename=$(basename "$existingFile")
# skip files with extensions
if [[ "$filename" == *.* ]]; then
continue
fi
# if the file doesn't exist in the contracts list, remove it
if ! echo "$contracts" | grep -qx "$filename"; then
rm -f "$existingFile"
CHANGED=1
fi
done
exit $CHANGED