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

remote-origin-url

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remote-origin-url - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

LICENSE

59

index.js

@@ -1,7 +0,6 @@

/*
* remote-origin-url
* https://github.com/jonschlinkert/remote-origin-url
/*!
* remote-origin-url <https://github.com/jonschlinkert/remote-origin-url>
*
* Copyright (c) 2014 Jon Schlinkert
* Licensed under the MIT license.
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/

@@ -11,23 +10,39 @@

var fs = require('fs');
var path = require('path');
var ini = require('ini');
var chalk = require('chalk');
var findup = require('findup-sync');
var parse = require('parse-git-config');
var warn = chalk.yellow;
/**
* Expose `originUrl`
*/
var origin = module.exports = function(dir) {
var git = findup('.git/config', {cwd: dir || process.cwd()});
var str = fs.readFileSync(git, 'utf8');
return ini.parse(str);
};
origin.url = function(dir) {
module.exports = originUrl;
function originUrl(cwd, cb) {
if (typeof cwd === 'function') {
cb = cwd;
cwd = null;
}
parse(cwd, function (err, parsed) {
if (err) {
if (err.code === 'ENOENT') {
cb(new Error('.git/config does not exist'));
return;
}
cb(err);
return;
}
var origin = parsed['remote "origin"'];
cb(null, origin && origin.url);
});
}
originUrl.sync = function(cwd) {
try {
return origin(dir)['remote "origin"'].url;
} catch(e) {
e += '\n[remote-origin-url]: ' + warn('This probably means that a remote origin has not been defined for this repository yet.');
return new Error(e);
var parsed = parse.sync(cwd);
var origin = parsed['remote "origin"'];
return origin && origin.url;
} catch(err) {
throw err;
}
};
};
{
"name": "remote-origin-url",
"description": "Get the git remote origin URL from your local git repository. Remember! A remote origin must exist first!",
"version": "0.2.1",
"version": "0.3.0",
"homepage": "https://github.com/jonschlinkert/remote-origin-url",

@@ -17,7 +17,8 @@ "author": {

},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jonschlinkert/remote-origin-url/blob/master/LICENSE-MIT"
}
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/remote-origin-url/blob/master/LICENSE"
},
"files": [
"index.js"
],

@@ -28,11 +29,11 @@ "main": "index.js",

},
"devDependencies": {
"chai": "~1.9.0",
"mocha": "~1.17.1"
"scripts": {
"test": "mocha"
},
"dependencies": {
"chalk": "~0.4.0",
"findup-sync": "~0.1.2",
"ini": "~1.1.0"
"parse-git-config": "^0.1.0"
},
"devDependencies": {
"should": "^5.0.1"
},
"keywords": [

@@ -39,0 +40,0 @@ "git",

@@ -1,15 +0,12 @@

# remote-origin-url [![NPM version](https://badge.fury.io/js/remote-origin-url.png)](http://badge.fury.io/js/remote-origin-url)
# remote-origin-url [![NPM version](https://badge.fury.io/js/remote-origin-url.svg)](http://badge.fury.io/js/remote-origin-url) [![Build Status](https://travis-ci.org/jonschlinkert/remote-origin-url.svg)](https://travis-ci.org/jonschlinkert/remote-origin-url)
> Get the git remote origin URL from your local git repository. Remember! A remote origin must exist first!
## Installation
## Install with [npm](npmjs.org)
Install with [npm](https://npmjs.org/):
```bash
npm i remote-origin-url --save
```
### Install with [bower](https://github.com/bower/bower)
Install with [bower](https://github.com/bower/bower):
```bash

@@ -24,22 +21,56 @@ bower install remote-origin-url --save

```js
var origin = require('remote-origin-url');
console.log(origin.url());
// "https://github.com/jonschlinkert/remote-origin-url.git"
var url = require('remote-origin-url');
url(function (err, res) {
// res => "https://github.com/jonschlinkert/remote-origin-url.git"
})
```
Specify the "base" directory, excluding `.git`. Example:
Specify the `cwd` to use:
```js
url(__dirname, function (err, res) {
// res => "https://github.com/jonschlinkert/remote-origin-url.git"
})
```
origin.url(__dirname);
### sync
```js
url.sync();
//=> "https://github.com/jonschlinkert/remote-origin-url.git"
```
## Authors
Specify the `cwd` to use:
```js
url.sync(__dirname);
//=> "https://github.com/jonschlinkert/remote-origin-url.git"
```
## 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/remote-origin-url/issues)
## 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](http://twitter.com/jonschlinkert), contributors.
Released under the [MIT license](./LICENSE-MIT)
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
***
_This file was generated by [verb](https://github.com/assemble/verb) on February 25, 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