我相信这应该可行,因为预提交将运行脚本中定义的任何内容。
"scripts": {
"lint": "lint-staged",
},
"pre-commit": [
"lint"
],
"lint-staged": {
"*.js": [
"prettier --write",
"eslint",
"git add"
],
"*.jsx": [
"prettier --write",
"eslint",
"git add"
],
"*.scss": [
"stylelint --syntax=scss",
"git add"
]
},
链接未运行的控制台
hutber@hutber-blade /var/www/shipamax-web/frontend $ git add tests/
hutber@hutber-blade /var/www/shipamax-web/frontend $ git commit -m"another test"
[chore/create-circleci-build-rebase 5ff3f76] another test
1 file changed, 1 insertion(+), 1 deletion(-)
hutber@hutber-blade /var/www/shipamax-web/frontend $
文件夹结构
- /.git
- /frontend
--all fe code
--package.json
运行
Linux Mint 18.3
节点v8
npm v5
[编辑]
在npm install pre-commit -D
内张贴./frontend
张贴
所以我删除了npm pre-commit
并在pre-commit
内创建了一个/.git/hooks
文件,只是为了看看它是否会重命名该文件,没有这样的运气:
答案 0 :(得分:1)
只要您没有看到.git/hooks/pre-commit
(来自the npm pre-commit package)创建的npm install --save-dev pre-commit
文件,您就不会获得任何预提交操作。< / p>
从observing/pre-commit/install.js
检查日志以查看插件是否检测到.git文件夹(如果它是正确的)
console.log('pre-commit:');
console.log('pre-commit: Found .git folder in', git);