Skip to content

Commit

Permalink
update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Dec 5, 2020
1 parent b29ee2b commit 1e1b289
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@ Husky can prevent bad `git commit`, `git push` and more 🐶 _woof!_

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

**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.
**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/#/).

## Install

Expand Down
13 changes: 2 additions & 11 deletions package.json
Expand Up @@ -3,7 +3,6 @@
"version": "4.3.3",
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",
"bin": {
"husky": "./husky.js",
"husky-run": "./bin/run.js",
"husky-upgrade": "./lib/upgrader/bin.js"
},
Expand Down Expand Up @@ -93,16 +92,8 @@
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testPathIgnorePatterns": [
"node_modules",
"__env__.ts"
],
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
]
"testPathIgnorePatterns": ["node_modules", "__env__.ts"],
"moduleFileExtensions": ["ts", "js", "json", "node"]
},
"collective": {
"type": "opencollective",
Expand Down
15 changes: 8 additions & 7 deletions src/installer/bin.ts
Expand Up @@ -43,7 +43,12 @@ function getInitCwdEnv(): string {
if (INIT_CWD === undefined) {
const { name, version } = whichPMRuns()
throw new Error(
`INIT_CWD is not set, please check that your package manager supports it (${name} ${version})`
`INIT_CWD is not set, please check that your package manager supports it (${name} ${version})
Alternatively, you could set it manually:
INIT_CWD="$(pwd)" npm install husky --save-dev
Or upgrade to husky v5`
)
}

Expand Down Expand Up @@ -84,12 +89,8 @@ function run(): void {
checkGitVersion()
}

let cwd = process.argv[3]
if (cwd === undefined) {
cwd = getInitCwdEnv()
}

const userPkgDir = getUserPkgDir(cwd)
const INIT_CWD = getInitCwdEnv()
const userPkgDir = getUserPkgDir(INIT_CWD)
checkGitDirEnv()
const { absoluteGitCommonDir, relativeUserPkgDir } = getDirs(userPkgDir)

Expand Down

0 comments on commit 1e1b289

Please sign in to comment.