git-config-path
Advanced tools
Comparing version 0.2.0 to 0.2.1
29
index.js
@@ -10,26 +10,17 @@ /*! | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var home = require('os-homedir'); | ||
var exists = require('fs-exists-sync'); | ||
var extend = require('extend-shallow'); | ||
var homedir = require('homedir-polyfill'); | ||
module.exports = function(type) { | ||
var configPath = path.join(process.cwd(), '.git/config'); | ||
if (!exists(configPath) || type === 'global') { | ||
configPath = path.join(home(), '.gitconfig'); | ||
module.exports = function(type, options) { | ||
var opts = extend({cwd: process.cwd()}, options); | ||
var configPath = path.resolve(opts.cwd, '.git/config'); | ||
if (type === 'global') { | ||
configPath = path.join(homedir(), '.gitconfig'); | ||
} | ||
if (!exists(configPath)) { | ||
configPath = path.join(home(), '.config/git/config'); | ||
configPath = path.join(homedir(), '.config/git/config'); | ||
} | ||
if (!exists(configPath)) { | ||
configPath = null; | ||
} | ||
return configPath; | ||
return exists(configPath) ? configPath : null; | ||
}; | ||
function exists(fp) { | ||
try { | ||
fs.statSync(fp); | ||
return true; | ||
} catch (err) {} | ||
return false; | ||
} |
{ | ||
"name": "git-config-path", | ||
"description": "Resolve the path to the user's global .gitconfig.", | ||
"version": "0.2.0", | ||
"description": "Resolve the path to the user's local or global .gitconfig.", | ||
"version": "0.2.1", | ||
"homepage": "https://github.com/jonschlinkert/git-config-path", | ||
@@ -23,3 +23,5 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"os-homedir": "^1.0.1" | ||
"extend-shallow": "^2.0.1", | ||
"fs-exists-sync": "^0.1.0", | ||
"homedir-polyfill": "^1.0.0" | ||
}, | ||
@@ -50,2 +52,7 @@ "devDependencies": { | ||
"list": [ | ||
"git-branch", | ||
"git-repo-name", | ||
"git-user-name", | ||
"git-username", | ||
"is-git-url", | ||
"parse-git-config" | ||
@@ -52,0 +59,0 @@ ] |
@@ -1,4 +0,4 @@ | ||
# git-config-path [![NPM version](https://img.shields.io/npm/v/git-config-path.svg?style=flat)](https://www.npmjs.com/package/git-config-path) [![NPM downloads](https://img.shields.io/npm/dm/git-config-path.svg?style=flat)](https://npmjs.org/package/git-config-path) [![Build Status](https://img.shields.io/travis/jonschlinkert/git-config-path.svg?style=flat)](https://travis-ci.org/jonschlinkert/git-config-path) | ||
# git-config-path [![NPM version](https://img.shields.io/npm/v/git-config-path.svg?style=flat)](https://www.npmjs.com/package/git-config-path) [![NPM monthly downloads](https://img.shields.io/npm/dm/git-config-path.svg?style=flat)](https://npmjs.org/package/git-config-path) [![NPM total downloads](https://img.shields.io/npm/dt/git-config-path.svg?style=flat)](https://npmjs.org/package/git-config-path) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/git-config-path.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/git-config-path) | ||
> Resolve the path to the user's global .gitconfig. | ||
> Resolve the path to the user's local or global .gitconfig. | ||
@@ -10,3 +10,3 @@ ## Install | ||
```sh | ||
$ npm install git-config-path --save | ||
$ npm install --save git-config-path | ||
``` | ||
@@ -30,27 +30,28 @@ | ||
## Related projects | ||
## About | ||
You might also be interested in these projects: | ||
### Related projects | ||
[parse-git-config](https://www.npmjs.com/package/parse-git-config): Parse `.git/config` into a JavaScript object. sync or async. | [homepage](https://github.com/jonschlinkert/parse-git-config) | ||
* [git-branch](https://www.npmjs.com/package/git-branch): Get the current branch for a local git repository. | [homepage](https://github.com/jonschlinkert/git-branch) | ||
* [git-repo-name](https://www.npmjs.com/package/git-repo-name): Get the repository name from the git remote origin URL. | [homepage](https://github.com/jonschlinkert/git-repo-name) | ||
* [git-user-name](https://www.npmjs.com/package/git-user-name): Get a user's name from git config at the project or global scope, depending on… [more](https://github.com/jonschlinkert/git-user-name) | [homepage](https://github.com/jonschlinkert/git-user-name) | ||
* [git-username](https://www.npmjs.com/package/git-username): Get the username from a git remote origin URL. | [homepage](https://github.com/jonschlinkert/git-username) | ||
* [is-git-url](https://www.npmjs.com/package/is-git-url): Regex to validate that a URL is a git url. | [homepage](https://github.com/jonschlinkert/is-git-url) | ||
* [parse-git-config](https://www.npmjs.com/package/parse-git-config): Parse `.git/config` into a JavaScript object. sync or async. | [homepage](https://github.com/jonschlinkert/parse-git-config) | ||
## Contributing | ||
### Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/git-config-path/issues/new). | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
## Building docs | ||
### Building docs | ||
Generate readme and API documentation with [verb](https://github.com/verbose/verb): | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
```sh | ||
$ npm install verb && npm run docs | ||
``` | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
Or, if [verb](https://github.com/verbose/verb) is installed globally: | ||
```sh | ||
$ verb | ||
$ npm install -g verb verb-generate-readme && verb | ||
``` | ||
## Running tests | ||
### Running tests | ||
@@ -63,3 +64,3 @@ Install dev dependencies: | ||
## Author | ||
### Author | ||
@@ -71,3 +72,3 @@ **Jon Schlinkert** | ||
## License | ||
### License | ||
@@ -79,2 +80,2 @@ Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
_This file was generated by [verb](https://github.com/verbose/verb), v, on March 29, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 26, 2016._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6601
76
3
22
+ Addedextend-shallow@^2.0.1
+ Addedfs-exists-sync@^0.1.0
+ Addedhomedir-polyfill@^1.0.0
+ Addedextend-shallow@2.0.1(transitive)
+ Addedfs-exists-sync@0.1.0(transitive)
+ Addedhomedir-polyfill@1.0.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedparse-passwd@1.0.0(transitive)
- Removedos-homedir@^1.0.1
- Removedos-homedir@1.0.2(transitive)