@ambiere/project-root
v0.1.3
Published
The root of the project.
Downloads
10
Maintainers
Readme
project-root
Tiny and zero dependencies utility, that finds the root of npm project.
Install
npm install @ambiere/project-root
Usage
Example npm project structure:
/
└── root
├── .git
├── package.json
└── src
├── types
└── index.js
Find the root of the project in index.js
file:
import projectRootDir from "@ambiere/project-root"
const projectRoot = projectRootDir()
console.log(projectRoot) // → /root
API
projectRootDir(dir?)
Return the root directory of the npm project or undefined
if none could be found.
dir:
Type: string
Default: process.cwd
The directory to start the search.