@igorskyflyer/git-repo-url
v1.1.0
Published
๐ Gets the origin URL a local Git repository. ๐บ๏ธ
Maintainers
Readme
๐ Table of Contents
๐ค Features
- โก Async & sync modes - fetch the Git remote URL your way
- ๐ Custom directory - point to any folder, not just the current one
- ๐ก Input validation - blocks invalid or empty paths early
- ๐ซ Existence check - errors if the folder doesn't exist
- ๐ฅ Direct Git command - uses
git remote get-url originfor accuracy - โ Clean return - URL string if found, empty string if not
- ๐งฉ Errorโsafe - gracefully handles Git errors without crashing
- ๐ชถ Lightweight dependency - minimal overhead, fast execution
โ ๏ธ WARNING
This module requires that the
gitexecutable is installed and available in the system path.If not, it needs to be installed first.
๐ต๐ผ Usage
Install it by executing any of the following, depending on your preferred package manager:
pnpm add @igorskyflyer/git-repo-urlyarn add @igorskyflyer/git-repo-urlnpm i @igorskyflyer/git-repo-url๐คน๐ผ API
getRepoUrl(options?): Promise<string>
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.ts
import { getRepoUrlSync } from '@igorskyflyer/git-repo-url'
console.log(getRepoUrlSync()) // prints e.g. 'https://github.com/igorskyflyer/npm-duoscribi'๐ Changelog
๐ The changelog is available here, CHANGELOG.md.
๐ชช License
Licensed under the MIT license which is available here, MIT license.
๐ Support
๐งฌ Related
@igorskyflyer/recursive-readdir
๐ Provides recursive readdir() and readdirSync() functions. ๐
๐ผ Provides a way to check if the given path is the root drive/directory. โ
@igorskyflyer/vscode-folderpicker
โจ Provides a custom Folder Picker API + UI for Visual Studio Code. ๐จ
๐ธ Checks if a directory is a local Git repository. ๐ถ๏ธ
๐ An npm package for fetching Windows registry keys. ๐
๐จ๐ปโ๐ป Author
Created by Igor Dimitrijeviฤ (@igorskyflyer).
