Skip to content

Instantly share code, notes, and snippets.

@teabyii
Last active October 12, 2016 11:36
Show Gist options
  • Save teabyii/cbef22986ca607ea5f84b4cc08e811c8 to your computer and use it in GitHub Desktop.
Save teabyii/cbef22986ca607ea5f84b4cc08e811c8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 只检查提交的 src 下的 js 文件
eslint=./node_modules/.bin/eslint
result=0
for file in `git diff --cached --name-only`
do
if [[ $(echo $file | grep -E "^src\/.*\.js$" | wc -l) -gt 0 ]];
then
git show :$file | $eslint --stdin --stdin-filename $file
result=$((result|$?))
fi
done
exit $result
@JSFiend
Copy link

JSFiend commented Oct 12, 2016

66666666666

@mcattx
Copy link

mcattx commented Oct 12, 2016

只检查提交的 src 下的 js 文件

改成 # 只检查提交的 src/ 下的 js 文件 会好点?

这是 githooks 的脚本吗

@teabyii
Copy link
Author

teabyii commented Oct 12, 2016

恩,githooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment