Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1e1b289

Browse files
committedDec 5, 2020
update error message
1 parent b29ee2b commit 1e1b289

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Husky can prevent bad `git commit`, `git push` and more 🐶 _woof!_
88

99
**Announcement: Husky v5 has been published, to view v5 docs click [here](https://typicode.github.io/husky).**
1010

11-
**Note for npm 7 users** Currently `INIT_CWD` environment variable is missing in npm v7 and is required for Husky v4 to auto-install (https://github.com/npm/cli/issues/2033). To manually install husky v4, run `npx --no-install husky install .` or upgrade to husky v5.
11+
**Note for npm v7 users** Currently `INIT_CWD` environment variable is missing in npm v7 and is required for Husky v4 to auto-install (https://github.com/npm/cli/issues/2033). To manually install husky v4, run `INIT_CWD="$(pwd)" npm install husky --save-dev` or upgrade to [husky v5](https://typicode.github.io/husky/#/).
1212

1313
## Install
1414

‎package.json

+2-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "4.3.3",
44
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",
55
"bin": {
6-
"husky": "./husky.js",
76
"husky-run": "./bin/run.js",
87
"husky-upgrade": "./lib/upgrader/bin.js"
98
},
@@ -93,16 +92,8 @@
9392
"^.+\\.tsx?$": "ts-jest"
9493
},
9594
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
96-
"testPathIgnorePatterns": [
97-
"node_modules",
98-
"__env__.ts"
99-
],
100-
"moduleFileExtensions": [
101-
"ts",
102-
"js",
103-
"json",
104-
"node"
105-
]
95+
"testPathIgnorePatterns": ["node_modules", "__env__.ts"],
96+
"moduleFileExtensions": ["ts", "js", "json", "node"]
10697
},
10798
"collective": {
10899
"type": "opencollective",

‎src/installer/bin.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ function getInitCwdEnv(): string {
4343
if (INIT_CWD === undefined) {
4444
const { name, version } = whichPMRuns()
4545
throw new Error(
46-
`INIT_CWD is not set, please check that your package manager supports it (${name} ${version})`
46+
`INIT_CWD is not set, please check that your package manager supports it (${name} ${version})
47+
48+
Alternatively, you could set it manually:
49+
INIT_CWD="$(pwd)" npm install husky --save-dev
50+
51+
Or upgrade to husky v5`
4752
)
4853
}
4954

@@ -84,12 +89,8 @@ function run(): void {
8489
checkGitVersion()
8590
}
8691

87-
let cwd = process.argv[3]
88-
if (cwd === undefined) {
89-
cwd = getInitCwdEnv()
90-
}
91-
92-
const userPkgDir = getUserPkgDir(cwd)
92+
const INIT_CWD = getInitCwdEnv()
93+
const userPkgDir = getUserPkgDir(INIT_CWD)
9394
checkGitDirEnv()
9495
const { absoluteGitCommonDir, relativeUserPkgDir } = getDirs(userPkgDir)
9596

0 commit comments

Comments
 (0)
Please sign in to comment.