hus*_*ain 0 git node.js tslint
我正在尝试添加prehook,如果代码无法提交任何棉绒问题。什么是实现它的正确方法。
tslint.sh
#!/bin/sh
sh ./npm-install.sh
if [ $? -ne 0 ]; then
echo "npm-install error, exiting.."
exit 1
fi
echo "Running ts lint"
npm run lint
if [ $? -ne 0 ]; then
echo "Unit tests error, exiting.."
exit 1
fi
Run Code Online (Sandbox Code Playgroud)
我在以下方面具有成功的实施经验:
husky =>指定git hooklint-staged =>运行命令以在git中暂存文件(因此无需对所有文件运行tslint)参考:
在package.json指定lint-staged并pre-commit在husky现场:
"dependencies": ...,
"devDependencies": ...,
"scripts" ...,
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [ // target to all typescript files in staged stage in git
"npm run lint", // your lint command
"git add"
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3769 次 |
| 最近记录: |