Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antongolub/git-root

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antongolub/git-root

Find the closest .git containing path

  • 1.5.14
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
472
increased by2.39%
Maintainers
0
Weekly downloads
 
Created
Source

@antongolub/git-root

Find the closest .git containing path — the git root.

CI Maintainability Test Coverage npm (scoped)

Motivation

It's known for certain the best way to find git root:

git rev-parse --show-toplevel

However, if git executable or child_process.exec are not available for some (security?) reasons, it's advisable to use tools like this one. Inspired by pkg-dir.

Features

  • Searches for .git up the dir tree
  • Handles gitdir: </some/path.git> redirects
  • TS and Flow typings out of box
  • Sync/async methods

Install

yarn add @antongolub/git-root

Usage

import { gitRoot, gitRootSync } from '@antongolub/git-root'

// async
const gitRoot1 = await gitRoot('/optional/cwd/path/')

// sync
const gitRoot2 = gitRoot('/defaults/to/process/cwd/', true)

// sync too
const gitRoot3 = gitRoot.sync()

// `gitRootSync` is an alias for `gitRoot.sync`
const gitRoot4 = gitRootSync()

Alternatives

License

MIT

Keywords

FAQs

Package last updated on 06 Jul 2024

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc