Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 months ago
JSON representation
π Gets the origin URL of a local Git repository. πΊοΈ
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-git-repo-url
- Owner: igorskyflyer
- License: mit
- Created: 2024-07-28T22:31:13.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-02T19:55:26.000Z (5 months ago)
- Last Synced: 2024-09-30T03:03:26.081Z (3 months ago)
- Topics: back-end, directory, folder, git, github, gitlab, igorskyflyer, javascript, js, node, repo, repository, ts, typescript, url
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/git-repo-url
- Size: 71.3 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
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! ππ
@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/)).