From 552593b668f673f0a25d6f191e066629cce32cef Mon Sep 17 00:00:00 2001 From: Szymon Dzialowski <98088306+sd-godaddy@users.noreply.github.com> Date: Sun, 1 May 2022 11:17:16 +0100 Subject: [PATCH] docs: update husky hook adding (#3141) --- README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b5d2140f2a..6065454470 100644 --- a/README.md +++ b/README.md @@ -104,18 +104,23 @@ yarn add husky --dev npx husky install # or yarn husky install +``` -# Add hook -npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"' -# Sometimes above command doesn't work in some command interpreters -# You can try other commands below to write npx --no -- commitlint --edit $1 -# in the commit-msg file. -npx husky add .husky/commit-msg \"npx --no -- commitlint --edit '$1'\" -# or -npx husky add .husky/commit-msg "npx --no -- commitlint --edit $1" +### Add hook -# or -yarn husky add .husky/commit-msg 'yarn commitlint --edit $1' +```sh +cat < .husky/commit-msg +#!/bin/sh +. "\$(dirname "\$0")/_/husky.sh" + +npx --no -- commitlint --edit "\${1}" +EEE +``` + +Make hook executable + +```sh +chmod a+x .husky/commit-msg ``` Check the [husky documentation](https://typicode.github.io/husky/#/?id=manual) on how you can automatically have Git hooks enabled after install for different `yarn` versions.