Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorskyflyer/npm-is-git-repo
πΈ Checks if a directory is a local Git repository. πΆοΈ
https://github.com/igorskyflyer/npm-is-git-repo
back-end directory folder git github gitlab igorskyflyer javascript js node repo repository ts typescript
Last synced: 3 months ago
JSON representation
πΈ Checks if a directory is a local Git repository. πΆοΈ
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-is-git-repo
- Owner: igorskyflyer
- License: mit
- Created: 2024-07-28T22:37:43.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-02T19:45:57.000Z (5 months ago)
- Last Synced: 2024-09-30T03:03:25.890Z (4 months ago)
- Topics: back-end, directory, folder, git, github, gitlab, igorskyflyer, javascript, js, node, repo, repository, ts, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/is-git-repo
- Size: 54.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Is Git repo?
πΈ Checks if a directory is a local Git repository. πΆοΈ
π Support further development
I work hard for every project, including this one
and your support means a lot to me!
Consider buying me a coffee. β
Thank you for supporting my efforts! ππ
@igorskyflyer
## π Table of contents
- [Features](#-features)
- [Usage](#-usage)
- [API](#-api)
- [isGitRepo()](#isgitrepooptions-promiseboolean)
- [isGitRepoSync()](#isgitreposyncoptions-boolean)
- [Examples](#-examples)
- [Changelog](#-changelog)
- [License](#-license)
- [Related](#-related)
- [Author](#-author)
## π€ Features
- π checks if a directory is a Git repo
- β both async and sync methods supported
- π½ cross-platform
- βοΈ lightweight---
## π΅πΌ Usage
> [!WARNING]
> This module requires that the [`git`](https://git-scm.com) executable is installed and available in the system path.
>
> If not, it needs to be installed first.
>
Install the module by executing:
```shell
npm i '@igor.dvlpr/is-git-repo'
```---
## π€ΉπΌ API
### `isGitRepo(options?): Promise`
*Asynchronously checks if a local directory is a Git repository.*
`options` - Optional object with options:
- `directory` - Sets the current working directory, otherwise the current directory will be used instead.
Will throw an error if the passed directory is not valid or does not exist.
Returns a Boolean indicating whether provided local directory is a Git repository.
---
### `isGitRepoSync(options?): boolean`
*Synchronously checks if a local directory is a Git repository.*
`options` - Optional object with options:
- `directory` - Sets the current working directory, otherwise the current directory will be used instead.
Will throw an error if the passed directory is not valid or does not exist.
Returns a Boolean indicating whether provided local directory is a Git repository.
---
## β¨ Examples
`example.mts`
```ts
import { isGitRepoSync } from '@igor.dvlpr/is-git-repo'console.log(isGitRepoSync({ directory: '../my-git-project' })) // true
```---
## π Changelog
π The changelog is available here: [CHANGELOG.md](https://github.com/igorskyflyer/npm-is-git-repo/blob/main/CHANGELOG.md).
---
## πͺͺ License
Licensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-is-git-repo/blob/main/LICENSE).
---
## 𧬠Related
[@igor.dvlpr/vscode-folderpicker](https://www.npmjs.com/package/@igor.dvlpr/vscode-folderpicker)
> _β¨ Provides a custom Folder Picker API + UI for Visual Studio Code. π¨_
[@igor.dvlpr/git-repo-url](https://www.npmjs.com/package/@igor.dvlpr/git-repo-url)
> _π Gets the origin URL a local Git repository. πΊοΈ_
[@igor.dvlpr/is-rootdir](https://www.npmjs.com/package/@igor.dvlpr/is-rootdir)
> _πΌ Provides a way to check if the given path is the root drive/directory. β_
[@igor.dvlpr/str-is-in](https://www.npmjs.com/package/@igor.dvlpr/str-is-in)
> _𧡠Provides ways of checking whether a String is present in an Array of Strings using custom Comparators. π_
[@igor.dvlpr/chars-in-string](https://www.npmjs.com/package/@igor.dvlpr/chars-in-string)
> _πͺ Provides ways of testing whether an array of chars is present inside a given String. β_
---
## π¨π»βπ» Author
Created by **Igor DimitrijeviΔ** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).