Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/igorskyflyer/npm-git-repo-url

🌐 Gets the origin URL of a local Git repository. πŸ—ΊοΈ
https://github.com/igorskyflyer/npm-git-repo-url

back-end directory folder git github gitlab igorskyflyer javascript js node repo repository ts typescript url

Last synced: 3 days ago
JSON representation

🌐 Gets the origin URL of a local Git repository. πŸ—ΊοΈ

Awesome Lists containing this project

README

        

Git Repo URL



🌐 Gets the origin URL of 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! πŸ™πŸ˜Š





Donate to igorskyflyer




@igorskyflyer










## πŸ“ƒ Table of contents

- [Features](#-features)
- [Usage](#-usage)
- [API](#-api)
- [getRepoUrl()](#getrepourloptions-promisestring)
- [getRepoUrlSync()](#getrepourlsyncoptions-string)
- [Examples](#-examples)
- [Changelog](#-changelog)
- [License](#-license)
- [Related](#-related)
- [Author](#-author)




## πŸ€– Features

- πŸ” gets the URL of a local 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/git-repo-url'
```

---

## 🀹🏼 API

### `getRepoUrl(options?): Promise`

*Asynchronously gets the URL of a local directory if it 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 the URL if the directory is a Git repository, otherwise an empty string.

---

### `getRepoUrlSync(options?): string`

*Synchronously gets the URL of a local directory if it 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 the URL if the directory is a Git repository, otherwise an empty string.

---

## ✨ Examples

`example.mts`
```ts
import { getRepoUrlSync } from '@igor.dvlpr/git-repo-url'

console.log(getRepoUrlSync()) // prints e.g. 'https://github.com/igorskyflyer/npm-duoscribi'
```

---

## πŸ“ Changelog

πŸ“‘ The changelog is available here: [CHANGELOG.md](https://github.com/igorskyflyer/npm-git-repo-url/blob/main/CHANGELOG.md).

---

## πŸͺͺ License

Licensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-git-repo-url/blob/main/LICENSE).

---

## 🧬 Related

[@igor.dvlpr/recursive-readdir](https://www.npmjs.com/package/@igor.dvlpr/recursive-readdir)

> _πŸ“– Provides recursive readdir() and readdirSync() functions. πŸ“_


[@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/vscode-folderpicker](https://www.npmjs.com/package/@igor.dvlpr/vscode-folderpicker)

> _✨ Provides a custom Folder Picker API + UI for Visual Studio Code. 🎨_


[@igor.dvlpr/is-git-repo](https://www.npmjs.com/package/@igor.dvlpr/is-git-repo)

> _🐸 Checks if a directory is a local Git repository. πŸ•ΆοΈ_


[@igor.dvlpr/regkeys](https://www.npmjs.com/package/@igor.dvlpr/regkeys)

> _πŸ“š An npm package for fetching Windows registry keys. πŸ—_

---

## πŸ‘¨πŸ»β€πŸ’» Author
Created by **Igor Dimitrijević** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).