首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Is there a Git pre-commit hook?

Is there a Git pre-commit hook?

有趣的你应该问!

#!/bin/bash  # Ensure all JavaScript files staged for commit pass standard code style function xargs-r() {  # Portable version of "xargs -r". The -r flag is a GNU extension that   # prevents xargs from running if there are no input files.   if IFS= read -r -d $'\n' path; then    { echo "$path"; cat; } | xargs $@  fi}git diff --name-only --cached --relative | grep '\.jsx\?$' | sed 's/[^[:alnum:]]/\\&/g' | xargs-r -E '' -t standardif [[ $? -ne 0 ]]; then  echo 'JavaScript Standard Style errors were detected. Aborting commit.'  exit 1fi

扫码关注腾讯云开发者

领取腾讯云代金券