“pre-commit”未在Linux

时间:2018-02-14 14:17:12

标签: git npm pre-commit

我相信这应该可行,因为预提交将运行脚本中定义的任何内容。

  "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张贴 enter image description here

文件夹结构 enter image description here

所以我删除了npm pre-commit并在pre-commit内创建了一个/.git/hooks文件,只是为了看看它是否会重命名该文件,没有这样的运气:

enter image description here

1 个答案:

答案 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);