Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

git-username

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-username - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

LICENSE

41

index.js
/*!
* git-username <https://github.com/jonschlinkert/git-username>
*
* Copyright (c) 2014 Jon Schlinkert
* Licensed under the MIT License (MIT)
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
const url = require('url');
const origin = require('remote-origin-url');
const gitUrl = require('github-url-from-git');
const log = require('verbalize');
var url = require('url');
var chalk = require('chalk');
var origin = require('remote-origin-url');
/**
* Expose `username`
*/
module.exports = username;
/**
* Get the username from the GitHub remote origin URL
*/
module.exports = (function() {
if (/\bhas not been defined\b/.test(origin.url())) {
log.warn(" Can't calculate git-username. This probably means that");
log.warn(" a git remote origin has not been defined.");
return '';
function username(cwd) {
var repo = origin.sync(cwd);
if (!repo) {
console.error(chalk.red(' Can\'t calculate git-username, which probably means that\n a git remote origin has not been defined.'));
}
return url.parse(gitUrl(origin.url())).path.split('/')[1];
})();
var o = url.parse(repo);
var path = o.path
if (path.length && path.charAt(0) === '/') {
path = path.slice(1);
}
path = path.split('/')[0];
return path;
};
console.log(username())
{
"name": "git-username",
"description": "Extract the username from a git remote origin URL.",
"version": "0.2.0",
"description": "Get the username from a git remote origin URL.",
"version": "0.3.0",
"homepage": "https://github.com/jonschlinkert/git-username",

@@ -17,17 +17,9 @@ "author": {

},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jonschlinkert/git-username/blob/master/LICENSE-MIT"
}
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/git-username/blob/master/LICENSE"
},
"files": [
"index.js"
],
"keywords": [
"docs",
"documentation",
"generate",
"generator",
"markdown",
"templates",
"verb"
],
"main": "index.js",

@@ -38,12 +30,23 @@ "engines": {

"scripts": {
"test": "mocha -R test"
"test": "mocha"
},
"dependencies": {
"chalk": "^1.0.0",
"remote-origin-url": "^0.3.0"
},
"devDependencies": {
"verb": "~0.2.0"
"mocha": "*"
},
"dependencies": {
"github-url-from-git": "~1.1.1",
"remote-origin-url": "~0.2.1",
"verbalize": "^0.1.2"
}
"keywords": [
"parse",
"git",
"name",
"origin",
"remote",
"remote origin url",
"remote origin",
"url",
"user",
"username"
]
}

@@ -1,10 +0,7 @@

# git-username [![NPM version](https://badge.fury.io/js/git-username.png)](http://badge.fury.io/js/git-username)
# git-username [![NPM version](https://badge.fury.io/js/git-username.svg)](http://badge.fury.io/js/git-username)
> Extract the username from a git remote origin URL.
> Get the username from a git remote origin URL.
This differs from [git-user-name](https://github.com/jonschlinkert/git-user-name), which provides name of the current user from git config.
## Install with [npm](npmjs.org)
## Install
Install with [npm](npmjs.org):
```bash

@@ -14,30 +11,44 @@ npm i git-username --save

## Usage
```js
var username = require('git-username');
console.log(username);
var username = require('git-username')();
//=> jonschlinkert
```
## Related
Here are a few related projects:
+ [git-branch](https://github.com/jonschlinkert/git-branch): Get the current branch for a local git repository
+ [git-repo-name](https://github.com/jonschlinkert/git-repo-name): Get the repository name from the git remote origin URL
+ [git-user-email](https://github.com/jonschlinkert/git-user-email): Get the current user's git email address.
+ [git-user-name](https://github.com/jonschlinkert/git-user-name): Get the name of the current user from git config, at the project or global scope, depending on what git uses in the current context.
+ [git-username](https://github.com/jonschlinkert/git-username): Get the username from a git remote origin URL.
+ [github-repo-url](https://github.com/jonschlinkert/github-repo-url): Extract a GitHub project's URL from its git repository URL.
Optionally pass a CWD as the second argument:
```js
var username = require('git-username')('foo');
```
## Run tests
Install dev dependencies:
```bash
npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/git-username/issues)
## Related projects
* [git-branch](https://github.com/jonschlinkert/git-branch): Get the current branch for a local git repository.
* [git-repo-name](https://github.com/jonschlinkert/git-repo-name): Get the repository name from the git remote origin URL.
* [git-user-email](https://github.com/jonschlinkert/git-user-email): Get the git email address of the current user.
* [git-user-name](https://github.com/jonschlinkert/git-user-name): Get the name of the current user from git config, at the project or global scope, depending on what git uses in the current context.
* [git-username](https://github.com/jonschlinkert/git-username): Extract the username from a git remote origin URL.
* [github-repo-url](https://github.com/jonschlinkert/github-repo-url): Extract a GitHub project's URL from its git repository URL.
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2014 Jon Schlinkert, contributors.
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license

@@ -47,2 +58,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 04, 2014._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on February 27, 2015._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc