用于Redux State的序列化檢查
#!/bin/sh
# check redux states serializer start
set u
set e
path="yourPath/serializers.dart";
s="`cat ${path} |grep ,`";
array=(`echo ${s} |tr ',' ' '` )
echo "\033[30;33mCheck serializer for redux states!\033[0m";
for i in`find ./YourCheckFolder -name"*_state.dart"`;
do (j=`cat ${i} |grep static\ Serializer\<`;
k=`cat ${i} |grep "implements\ Built"`;
if [[ -z${j}]]
then
? ? ? echo "\033[30;33m${i}: not a real state file!\033[0m"
? ? else
? ? ? if [[ -z${j}]]
then
? ? ? ? ? echo "\033[31mError checked: $i , because no serializer!!\033[0m";
else
? ? ? ? ? echo "\033[32m${i}: ok\033[0m"
? ? ? fi
? ? ? array2=(`echo ${j}` );
for var in${array2[@]}
do
? ? ? ? ? if [[ "${var}" =~ "Serializer<"]];then
? ? ? ? ? ? ? state=${var#*<}
state=${state%>}
if [[ ! " ${array[@]}" =~ " ${state} "]];then
? ? ? ? ? ? ? ? ? echo "\033[31m${path}: not register ${state}!\033[0m"
? ? ? ? ? ? ? fi
fi
done
fi
);
done
# check redux states serializer end