
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
repo-utils
Advanced tools
Utils for normalizing and formatting repo data.
Install with npm:
$ npm install repo-utils --save
var repoUtils = require('repo-utils');
Get the name
for a repository from: - github repository path (owner/project-name
) - github URL - absolute file path to a directory on the local file system (.
and ''
may be used as aliases for the current working directory)
Params
cwd
{String}: Absolute file path or github URLreturns
{String}: Project nameExample
repoUtils.name(process.cwd());
//=> 'repo-utils'
repoUtils.name('.');
//=> 'repo-utils'
repoUtils.name();
//=> 'repo-utils'
repoUtils.name('https://github.com/jonschlinkert/repo-utils');
//=> 'repo-utils'
repoUtils.name('jonschlinkert/repo-utils');
//=> 'repo-utils'
Create a github repository string in the form of owner/name
, from: - full github repository URL - object returned from url.parse
- list of arguments in the form of owner, name
Params
owner
{String}: Repository ownername
{String}: Repository namereturns
{String}: RepsExample
repoUtils.repository('jonschlinkert', 'micromatch');
//=> 'jonschlinkert/micromatch'
repoUtils.repository({owner: 'jonschlinkert', repository: 'micromatch'});
//=> 'jonschlinkert/micromatch'
repoUtils.repository('https://github.com/jonschlinkert/micromatch');
//=> 'jonschlinkert/micromatch'
Create a homepage
URL from a github repository path or github repository URL.
Params
repository
{String}: Repository in the form of owner/project-name
options
{Object}returns
{String}: Formatted github homepage url.Example
repoUtils.homepage('jonschlinkert/repo-utils');
//=> 'https://github.com/jonchlinkert/repo-utils'
Create a GitHub issues
URL.
Params
repository
{String}: Repository in the form of owner/project-name
or full github project URL.options
{Object}returns
{String}Example
repoUtils.isses('jonschlinkert/micromatch');
//=> 'https://github.com/jonchlinkert/micromatch/issues'
Create a GitHub bugs
URL. Alias for .issues.
Params
repository
{String}: Repository in the form of owner/project-name
options
{Object}returns
{String}Example
repoUtils.bugs('jonschlinkert/micromatch');
//=> 'https://github.com/jonchlinkert/micromatch/issues'
Create a github https
URL.
Params
repository
{String}: Repository in the form of owner/project-name
options
{Object|String}: Options object or optional branchbranch
{String}: Optionally specify a branchreturns
{String}Example
repoUtils.https('jonschlinkert/micromatch');
//=> 'https://github.com/jonchlinkert/micromatch'
Create a travis URL.
Params
repository
{String}: Repository in the form of owner/project-name
options
{Object|String}: Options object or optional branchbranch
{String}: Optionally specify a branchreturns
{String}Example
repoUtils.travis('jonschlinkert/micromatch');
//=> 'https://travis-ci.org/jonschlinkert/micromatch'
Create a URL for a file in a github repository.
Params
repository
{String}: Repository in the form of owner/project-name
or full GitHub repository URL.branch
{String}: Optionally specify a branchpath
{String}: Path to the file, relative to the repository root.returns
{String}Example
repoUtils.file('https://github.com/jonschlinkert/micromatch', 'README.md');
//=> 'https://raw.githubusercontent.com/jonschlinkert/micromatch/master/README.md'
repoUtils.raw('jonschlinkert/micromatch', 'README.md');
//=> 'https://raw.githubusercontent.com/jonschlinkert/micromatch/master/README.md'
Create a github "raw" content URL.
Params
repository
{String}: Repository in the form of owner/project-name
options
{Object|String}: Options object or optional branchbranch
{String}: Optionally specify a branchreturns
{String}Example
repoUtils.raw('https://github.com/jonschlinkert/micromatch', 'README.md');
//=> 'https://raw.githubusercontent.com/jonschlinkert/micromatch/master/README.md'
repoUtils.raw('jonschlinkert/micromatch', 'README.md');
//=> 'https://raw.githubusercontent.com/jonschlinkert/micromatch/master/README.md'
Return true if the given string looks like a github URL.
Params
str
{String}: URL to testreturns
{Boolean}Example
utils.isGithubUrl('https://github.com/whatever');
//=> true
utils.isGithubUrl('https://foo.com/whatever');
//=> false
Parse a GitHub repository URL or repository owner/project-name
into an object.
Params
repositoryURL
{String}: Full repository URL, or repository path in the form of owner/project-name
options
{Object}returns
{Boolean}Example
// see the tests for supported formats
repoUtils.parse('https://raw.githubusercontent.com/jonschlinkert/micromatch/master/README.md');
// results in:
{ protocol: 'https:',
slashes: true,
hostname: 'raw.githubusercontent.com',
host: 'raw.githubusercontent.com',
pathname: 'https://raw.githubusercontent.com/foo/bar/master/README.md',
path: '/foo/bar/master/README.md',
href: 'https://raw.githubusercontent.com/foo/bar/master/README.md',
owner: 'foo',
name: 'bar',
repo: 'foo/bar',
repository: 'foo/bar',
branch: 'master' }
Parse a GitHub repository
path or URL by calling repo.parse()
, then expands it into an object of URLs. (the object also includes properties returned from .parse()
). A file path maybe be passed as the second argument to include raw
and file
properties in the result.
Params
repository
{String}file
{String}: Optionally pass a repository file path.returns
{String}Example
// see the tests for supported formats
repoUtils.expand('https://github.com/abc/xyz.git', 'README.md');
// results in:
{ protocol: 'https:',
slashes: true,
hostname: 'github.com',
host: 'github.com',
pathname: 'https://github.com/abc/xyz.git',
path: '/abc/xyz.git',
href: 'https://github.com/abc/xyz.git',
owner: 'abc',
name: 'xyz',
repo: 'abc/xyz',
repository: 'abc/xyz',
branch: 'master',
host_api: 'api.github.com',
host_raw: 'https://raw.githubusercontent.com',
api: 'https://api.github.com/repos/abc/xyz',
tarball: 'https://api.github.com/repos/abc/xyz/tarball/master',
clone: 'https://github.com/abc/xyz',
zip: 'https://github.com/abc/xyz/archive/master.zip',
https: 'https://github.com/abc/xyz',
travis: 'https://travis-ci.org/abc/xyz',
file: 'https://github.com/abc/xyz/blob/master/README.md',
raw: 'https://raw.githubusercontent.com/abc/xyz/master/README.md' }
As of March 28, 2016:
Statements : 100% ( 131/131 )
Branches : 100% ( 68/68 )
Functions : 100% ( 15/15 )
Lines : 100% ( 131/131 )
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v, on March 28, 2016.
FAQs
Utils for normalizing and formatting repo data.
The npm package repo-utils receives a total of 22,127 weekly downloads. As such, repo-utils popularity was classified as popular.
We found that repo-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.