UNPKG

@bevry/update-contributors

Version:

Update the package.json author, contributors, and maintainers fields with the latest remote data

21 lines (20 loc) 628 B
export function getGitHubRepoSlug(pkg) { let match = null; if (typeof pkg.repository === 'string') { match = pkg.repository.match(/^(?:github:)?([^/:]+\/[^/:]+)$/); } else { let url = null; if (pkg.repository && typeof pkg.repository.url === 'string') { url = pkg.repository && pkg.repository.url; } else if (typeof pkg.homepage === 'string') { url = pkg.homepage; } else { return null; } match = url.match(/github\.com\/([^/:]+\/[^/:]+?)(?:\.git|\/)?$/); } return (match && match[1]) || null; }