top-pkg-dir
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

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.

/top-pkg-dir/

    Package Sidebar

    Install

    npm i top-pkg-dir

    Weekly Downloads

    10

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    7.92 kB

    Total Files

    7

    Last publish

    Collaborators

    • ozum