Skip to content

Commit 06d15d3

Browse files
committedNov 11, 2020
docs: update custom directory instructions
1 parent 98997a9 commit 06d15d3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed
 

‎docs/README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,22 @@ If `npm test` command fails, your commit will be automatically aborted.
8686

8787
It's recommended to add husky in root `package.json`. You can use tools like [lerna](https://github.com/lerna/lerna) and filters to only run scripts in packages that have been changed.
8888

89-
## Subdirectory
89+
## Custom directory
9090

91-
By design, `husky install` must be run in the same directory as `.git` but you can indicate where your git hooks are.
91+
If you want to install husky in another directory, for example `.config`, you can pass it to `install` command. For example:
9292

93-
For example, if your `package.json` is in a subdirectory (.e.g `front/`), you can change directory during `postinstall` and specify where your git hooks are:
93+
```
94+
// package.json
95+
{
96+
"scripts": {
97+
"postinstall": "husky install .config"
98+
}
99+
}
100+
```
101+
102+
Another case you may be in is if your `package.json` file and `.git` directory are not at the same level. For example, `project/.git` and `project/front/.package.json`.
103+
104+
By design, `husky install` must be run in the same directory as `.git`, but you can change directory during `postinstall` script and pass a subdirectory:
94105

95106
```js
96107
// package.json

0 commit comments

Comments
 (0)
Please sign in to comment.