Socket
Socket
Sign inDemoInstall

git-root-dir

Package Overview
Dependencies
6
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    git-root-dir

Find the root directory of a `git` repository


Version published
Maintainers
1
Install size
34.5 kB
Created

Readme

Source

git-root-dir

Package Version Downloads Status Build Status: Linux Coverage Status

Find the root directory of a git repository.

Useful for tools that need to know whether git is managing the things inside.

Installation

npm install --save git-root-dir

Usage

/
└── Users
    └── luftywiranda
        └── foo
            ├── .git
            └── bar
                ├── baz
                └── example.js
// example.js
const gitRootDir = require('git-root-dir');

gitRootDir(__dirname).then(rootDir => {
  console.log(rootDir);
  //=> '/Users/luftywiranda/foo'
});

API

gitRootDir([cwd])

Returns a Promise for either the repository root path or null if it couldn't be found.

cwd

Type: string
Default: process.cwd()

Directory to start from.

  • git-dir-up – Find the closest .git directory
  • pkg-dir – Find the root directory of a Node.js project or npm package

License

MIT © Lufty Wiranda

Keywords

FAQs

Last updated on 13 Jan 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc