git-config-path
Advanced tools
Comparing version 1.0.1 to 2.0.0
30
index.js
/*! | ||
* git-config-path <https://github.com/jonschlinkert/git-config-path> | ||
* | ||
* Copyright (c) 2015, Jon Schlinkert. | ||
* Copyright (c) 2015-present, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
@@ -10,6 +10,5 @@ */ | ||
var path = require('path'); | ||
var exists = require('fs-exists-sync'); | ||
var extend = require('extend-shallow'); | ||
var homedir = require('homedir-polyfill'); | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
@@ -22,18 +21,17 @@ module.exports = function(type, options) { | ||
var opts = extend({cwd: process.cwd()}, options); | ||
type = type || opts.type; | ||
let opts = Object.assign({ cwd: process.cwd(), type }, options); | ||
let configPath; | ||
var configPath = path.resolve(opts.cwd, '.git/config'); | ||
if (type === 'global') { | ||
configPath = path.join(homedir(), '.gitconfig'); | ||
if (opts.type === 'global') { | ||
configPath = path.join(os.homedir(), '.gitconfig'); | ||
} else { | ||
configPath = path.resolve(opts.cwd, '.git/config'); | ||
} | ||
if (!exists(configPath)) { | ||
if (typeof type === 'string') { | ||
return null; | ||
} | ||
configPath = path.join(homedir(), '.config/git/config'); | ||
if (!fs.existsSync(configPath)) { | ||
if (typeof opts.type === 'string') return null; | ||
configPath = path.join(os.homedir(), '.config/git/config'); | ||
} | ||
return exists(configPath) ? configPath : null; | ||
return fs.existsSync(configPath) ? configPath : null; | ||
}; |
{ | ||
"name": "git-config-path", | ||
"description": "Resolve the path to the user's local or global .gitconfig.", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/jonschlinkert/git-config-path", | ||
@@ -17,3 +17,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -23,10 +23,5 @@ "scripts": { | ||
}, | ||
"dependencies": { | ||
"extend-shallow": "^2.0.1", | ||
"fs-exists-sync": "^0.1.0", | ||
"homedir-polyfill": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"gulp-format-md": "^0.1.7", | ||
"mocha": "^2.4.5" | ||
"gulp-format-md": "^2.0.0", | ||
"mocha": "^5.2.0" | ||
}, | ||
@@ -61,5 +56,2 @@ "keywords": [ | ||
}, | ||
"reflinks": [ | ||
"verb" | ||
], | ||
"lint": { | ||
@@ -66,0 +58,0 @@ "reflinks": true |
@@ -1,5 +0,7 @@ | ||
# 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) | ||
# 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 local or global .gitconfig. | ||
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. | ||
## Install | ||
@@ -31,33 +33,44 @@ | ||
### Related projects | ||
<details> | ||
<summary><strong>Contributing</strong></summary> | ||
* [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 | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Building docs | ||
</details> | ||
_(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).)_ | ||
<details> | ||
<summary><strong>Running Tests</strong></summary> | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
$ npm install && npm test | ||
``` | ||
### Running tests | ||
</details> | ||
Install dev dependencies: | ||
<details> | ||
<summary><strong>Building docs</strong></summary> | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
</details> | ||
### Related projects | ||
You might also be interested in these projects: | ||
* [git-branch](https://www.npmjs.com/package/git-branch): Get the current branch from the local git repository. | [homepage](https://github.com/jonschlinkert/git-branch "Get the current branch from the local git repository.") | ||
* [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 "Get the repository name from the git remote origin URL.") | ||
* [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 "Get a user's name from git config at the project or global scope, depending on what git uses in the current context.") | ||
* [git-username](https://www.npmjs.com/package/git-username): Get the username (or 'owner' name) from a git/GitHub remote origin URL. | [homepage](https://github.com/jonschlinkert/git-username "Get the username (or 'owner' name) from a git/GitHub remote origin URL.") | ||
* [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 "Regex to validate that a URL is a 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 "Parse `.git/config` into a JavaScript object. sync or async.") | ||
### Author | ||
@@ -67,12 +80,13 @@ | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [GitHub Profile](https://github.com/jonschlinkert) | ||
* [Twitter Profile](https://twitter.com/jonschlinkert) | ||
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/git-config-path/blob/master/LICENSE). | ||
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 26, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 18, 2018._ |
Sorry, the diff of this file is not supported yet
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
7458
0
90
28
- Removedextend-shallow@^2.0.1
- Removedfs-exists-sync@^0.1.0
- Removedhomedir-polyfill@^1.0.0
- Removedextend-shallow@2.0.1(transitive)
- Removedfs-exists-sync@0.1.0(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedis-extendable@0.1.1(transitive)
- Removedparse-passwd@1.0.0(transitive)