2

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

4
  • 1
    and pre-commit is in your devDependency? The page for pre-commit says that it modifies .git/hooks/pre-commit and moves the old one to .git/hooks/pre-commit.old -do you see those files? Commented Feb 14, 2018 at 14:41
  • Good point, I do not see these files. Commented Feb 14, 2018 at 21:44
  • did you manually add pre-commit to your dependencies in package.json? You probably have to use npm to install it so it knows to add those hooks to your git package. Run npm install --save-dev pre-commit so it installs correctly Commented Feb 14, 2018 at 22:00
  • Just tried this and have updated my question to show the findings, but it did not solve my issues Commented Feb 15, 2018 at 10:10

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

1 Comment

I will have to check the logs, I'll report back, thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.