* Resolves the project root during the postinstall step. * * Prefers INIT_CWD — the directory the package manager was invoked from, which * npm, pnpm, yarn, and bun all set to the project root when running lifecycle * scripts. Unlike getProjectRootDirectoryFromNodeModules, it does not depend on
(initCwd = process.env.INIT_CWD, cwd = process.cwd())
| 160 | * @return {string} - an absolute path to the project root |
| 161 | */ |
| 162 | function getProjectRootDirectory(initCwd = process.env.INIT_CWD, cwd = process.cwd()) { |
| 163 | if (initCwd && fs.existsSync(path.join(initCwd, 'package.json'))) { |
| 164 | return initCwd |
| 165 | } |
| 166 | |
| 167 | const parsedProjectDirectory = getProjectRootDirectoryFromNodeModules(cwd) |
| 168 | return parsedProjectDirectory !== undefined ? parsedProjectDirectory : cwd |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Checks the 'simple-git-hooks' in dependencies of the project |
no test coverage detected