-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd.sh
executable file
·62 lines (57 loc) · 1.79 KB
/
cmd.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
62
#!/bin/sh
usage="yarn <deploy,test> [-h] [-c <eth,bsc,polygon,avalanche,fantom,cronos,aurora,arbitrum,klaytn>] [-n <mainnet,testnet,ropsten,goerli,rinkeby,staging,fuji>] -- to run test on specific chain and network
where:
-h show this help text
-c which chain to run, supported <eth,bsc,polygon>
-n which network to run, supported <mainnet,testnet,ropsten,goerli,mumbai>
-f specific test to run if any"
# Default chain and network
CHAIN="eth"
NETWORK="goerli"
CMD="test"
while getopts ":hc:n:f:x:" option; do
case $option in
h)
echo "$usage"
exit
;;
c)
if [[ ! "$OPTARG" =~ ^(eth|bsc|polygon|avalanche|fantom|cronos|aurora|arbitrum|klaytn|optimism|linea|base)$ ]]; then
printf "invalid value for -%s\n" "$option" >&2
echo "$usage" >&2
exit 1
fi
CHAIN=$OPTARG;;
n)
if [[ ! "$OPTARG" =~ ^(mainnet|ropsten|goerli|rinkeby|testnet|mumbai|staging|fuji)$ ]]; then
printf "invalid value for -%s\n" "$option" >&2
echo "$usage" >&2
exit 1
fi
NETWORK=$OPTARG;;
f)
FILE=$OPTARG;;
x)
CMD=$OPTARG;;
:)
printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
*)
printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
if [ $CMD == "test" ]; then
if [ -n "$FILE" ]; then
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat test --no-compile --network hardhat $FILE
else
echo "Running all tests..."
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat test --no-compile --network hardhat
fi
elif [ $CMD == "deploy" ]; then
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat run scripts/deployer.ts --network "$CHAIN"_"$NETWORK"
fi