1.1.3 • Published 5 years ago

normalize-repo v1.1.3

Weekly downloads
115
License
MIT
Repository
github
Last release
5 years ago

Normalize Repo

Build Status npm bundle size npm version

Normalizes the repository object or string you typically find in package.json. It adheres to the specification and can parse everything you can also use as a value for repository.

Installation

yarn add normalize-repo

Examples

All values that repository

const normalizeRepo = require('normalize-repo');

normalizeRepo('github:krmax44/normalize-repo')

// output:
{
  url: 'https://github.com/krmax44/normalize-repo.git',
  shortcut: 'github:krmax44/normalize-repo',
  provider: 'github',
  owner: 'krmax44',
  name: 'normalize-repo'
}

You can also pass an object:

normalizeRepo({ url: 'https://github.com/krmax44/normalize-repo.git' });

A malformatted and incompliant input will throw an error:

try {
  // will throw an error, as only shortcut strings are allowed
  normalizeRepo('https://github.com/krmax44/normalize-repo.git');
} catch (error) {
  console.log(error);
}

Note: Only Github, Gitlab, Github Gist and Bitbucket repositories will return shortcut, provider, owner and name values.

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago