https://github.com/ozum/top-pkg-dir
Find top most root directory of a Node.js project or npm package.
https://github.com/ozum/top-pkg-dir
Last synced: about 2 months ago
JSON representation
Find top most root directory of a Node.js project or npm package.
- Host: GitHub
- URL: https://github.com/ozum/top-pkg-dir
- Owner: ozum
- License: mit
- Created: 2019-07-10T13:37:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T04:23:50.000Z (over 2 years ago)
- Last Synced: 2025-02-09T18:24:58.971Z (3 months ago)
- Language: TypeScript
- Size: 996 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# top-pkg-dir
Find top most root directory of a Node.js project or npm package.
# Example
```
└─ Development
└─ Projects
└─ project-a
├─ package.json
├─ lib
└─ node_modules
├─ project-b
└─ lib
└─ example.js
```**example.js**
```js
import topPkgDir from "top-pkg-dir";async function() {
const topProjectDir = await topPkgDir(); // '/Development/Projects/project-a'
}
```# API
## topPkgDir(cwd?)
Returns a `Promise` for either the top most project root path or `undefined` if it couldn't be found.
## topPkgDir.sync(cwd?)
Returns the top most project root path or `undefined` if it couldn't be found.
### cwd
Type: `string`
Default: `process.cwd()`Directory to start from.