Jamie Hutber
Jamie Hutber

Reputation: 28074

"pre-commit" not running in Linux

I believe this should work as pre-commit will run anything defined in scripts.

  "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"
    ]
  },

Console with link not running

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 $ 

Folder Structure

- /.git
- /frontend
--all fe code
--package.json

Running
Linux Mint 18.3
node v8
npm v5

[Edit]

Post running npm install pre-commit -D inside of ./frontend enter image description here

Folder structure enter image description here

so I removed npm pre-commit and created a pre-commit file inside /.git/hooks just to see if it would rename the file, no such luck:

enter image description here

Upvotes: 2

Views: 2558

Answers (1)

VonC
VonC

Reputation: 1324093

As long as you don't see a .git/hooks/pre-commit file created by npm install --save-dev pre-commit (from the npm pre-commit package), you won't get any pre-commit action.

From the observing/pre-commit/install.js check the logs to see if the plugin does detect your .git folder (and if it is the right one)

console.log('pre-commit:');
console.log('pre-commit: Found .git folder in', git);

Upvotes: 1

Related Questions