commonHook function
hooks template
Implementation
String commonHook(String path) {
var temp = '';
if (Platform.isMacOS) {
temp += 'source ~/.bash_profile\n';
}
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;
}