Extras
Adding Husky
Husky enhances your commits. We This section will go over:
- How to add Husky to your project
- How to configure it for pre-commits
You are strongly encouraged to follow the official documentation on how to setup your dependencies. Check out Husky's official documentation. For the stubborn ones, let's continue.
Remember to
cd .app before you start the instructions. These next commands should be ran from inside our .app directory.1. Install Husky
npm install --save-dev husky
2. Initiate Husky
npx husky init
3. Create New Scripts
- Open
.app/package.jsonand find thescriptssection. - Within it, add new
testentry and verify thepreparescript matches the one shown below:
"scripts": {
"prepare": "cd .. && husky .app/.husky",
"test": "npx @11ty/eleventy --dryrun"
}
4. Add New Hooks
Add the script test to our pre-commit.
echo "npm test" > .husky/pre-commit
5. Test Husky without a Commit
Add exit 1 to the hook script to exit the test without committing anything. for example:
npm test
exit 1
Having issues? Be sure to visit the official Troubleshooting page.