开发者社区> 镜像站> NPM> find-project-root
find-project-root
Finds project root
Last updated 5 years ago by kirstein .
ISC · Original npm · Tarball · package.json
$ cnpm install find-project-root 
SYNC missed versions from official npm registry.

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
  });

Current Tags

  • 1.1.1                                ...           latest (5 years ago)

4 Versions

  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 61
This Month 49
Last Day 10
Last Week 63
Last Month 197
Dependencies (0)
None
Dev Dependencies (2)