New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

find-project-root

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-project-root

Finds project root

  • 1.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created

find-project-root Build Status

Finds the project root by custom markers

Getting started

  1. As a binary

      $ npm install find-project-root -g
      $ pwd
        /Users/kirstein/workspace/github/kirstein/find-project-root/test
      $ find-project-root
        /Users/kirstein/workspace/github/kirstein/find-project-root
    
  2. As a node module

      $ npm install find-project-root
      var findProjectRoot = require('find-project-root');
      // magic
    

What?

Traverses top-down of the project tree starting from a specific path and searches for known markers that indicate project starting point.

Markers:

  • .hg
  • .git

API

findProjectRoot(path, {options});

options:

  • maxDepth - int - total number of levels the algorithm can traverse
    default: 9

  • markers - [ 'str' ] - markers that it will search for
    default: [ '.hg', '.git' ]

Example:
  var findProjectRoot = require('find-project-root');
  var root = findProjectRoot(process.cwd(), {
    maxDepth: 12
  });

FAQs

Package last updated on 18 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts