commonHook function
hooks template
Implementation
String commonHook(String path) {
var temp = '';
if (Platform.isMacOS) {
temp += '''
if [ -f ~/.bash_profile ]
then
source ~/.bash_profile
fi
if [ -f ~/.zsh_profile ]
then
source ~/.zsh_profile
fi
''';
}
temp += '''
hookName=`basename "\$0"`
gitParams="\$*"
program_exists() {
local ret="0"
command -v \$1 >/dev/null 2>&1 || { local ret="1"; }
if [ "\$ret" -ne 0 ]; then
return 1
fi
return 0
}
if program_exists dart; then
dart ${path} \$hookName
if [ "\$?" -ne "0" ];then
exit 1
fi
else
echo "git_hooks > \$hookName"
echo "Cannot find dart in PATH"
fi
''';
return temp;
}