Native Git Hooks

First, create the .hooks folder in your project. Add the pre-commit file and grant it executable permission with chmod +x .hooks/pre-commit

#!/bin/sh
echo "pre-commit hook run"

Now, let’s open the package.json file and add the following line to scripts.

{
  "scripts": {
    "prepare": "git config core.hooksPath .hooks",
  }
}

Now you can run install for running prepare scripts.