initial commit
This commit is contained in:
21
node_modules/parse-git-config/LICENSE
generated
vendored
Normal file
21
node_modules/parse-git-config/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
268
node_modules/parse-git-config/README.md
generated
vendored
Normal file
268
node_modules/parse-git-config/README.md
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
# parse-git-config [](https://www.npmjs.com/package/parse-git-config) [](https://npmjs.org/package/parse-git-config) [](https://npmjs.org/package/parse-git-config) [](https://travis-ci.org/jonschlinkert/parse-git-config)
|
||||
|
||||
> Parse `.git/config` into a JavaScript object. sync or async.
|
||||
|
||||
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
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save parse-git-config
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const parse = require('parse-git-config');
|
||||
|
||||
// sync
|
||||
console.log(parse.sync());
|
||||
|
||||
// using async/await
|
||||
(async () => console.log(await parse()))();
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### cwd
|
||||
|
||||
The starting directory to search from.
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Default**: `process.cwd()` (current working directory)
|
||||
|
||||
### path
|
||||
|
||||
Either the absolute path to .git `config`, or the path relative to the current working directory.
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Default**: `.git/config`
|
||||
|
||||
### Examples config object
|
||||
|
||||
Parsed config object will look something like:
|
||||
|
||||
```js
|
||||
{ core:
|
||||
{ repositoryformatversion: '0',
|
||||
filemode: true,
|
||||
bare: false,
|
||||
logallrefupdates: true,
|
||||
ignorecase: true,
|
||||
precomposeunicode: true },
|
||||
'remote "origin"':
|
||||
{ url: 'https://github.com/jonschlinkert/parse-git-config.git',
|
||||
fetch: '+refs/heads/*:refs/remotes/origin/*' },
|
||||
'branch "master"': { remote: 'origin', merge: 'refs/heads/master', ... } }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### [parse](index.js#L42)
|
||||
|
||||
Asynchronously parse a `.git/config` file. If only the callback is passed, the `.git/config` file relative to `process.cwd()` is used.
|
||||
|
||||
**Params**
|
||||
|
||||
* `options` **{Object|String|Function}**: Options with `cwd` or `path`, the cwd to use, or the callback function.
|
||||
* `callback` **{Function}**: callback function if the first argument is options or cwd.
|
||||
* `returns` **{Object}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
parse((err, config) => {
|
||||
if (err) throw err;
|
||||
// do stuff with config
|
||||
});
|
||||
|
||||
// or, using async/await
|
||||
(async () => {
|
||||
console.log(await parse());
|
||||
console.log(await parse({ cwd: 'foo' }));
|
||||
console.log(await parse({ cwd: 'foo', path: 'some/.git/config' }));
|
||||
})();
|
||||
```
|
||||
|
||||
### [.sync](index.js#L88)
|
||||
|
||||
Synchronously parse a `.git/config` file. If no arguments are passed, the `.git/config` file relative to `process.cwd()` is used.
|
||||
|
||||
**Params**
|
||||
|
||||
* `options` **{Object|String}**: Options with `cwd` or `path`, or the cwd to use.
|
||||
* `returns` **{Object}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
console.log(parse.sync());
|
||||
console.log(parse.sync({ cwd: 'foo' }));
|
||||
console.log(parse.sync({ cwd: 'foo', path: 'some/.git/config' }));
|
||||
```
|
||||
|
||||
### [.expandKeys](index.js#L134)
|
||||
|
||||
Returns an object with only the properties that had ini-style keys converted to objects.
|
||||
|
||||
**Params**
|
||||
|
||||
* `config` **{Object}**: The parsed git config object.
|
||||
* `returns` **{Object}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const config = parse.sync({ path: '/path/to/.gitconfig' });
|
||||
const obj = parse.expandKeys(config);
|
||||
```
|
||||
|
||||
### .expandKeys examples
|
||||
|
||||
Converts ini-style keys into objects:
|
||||
|
||||
**Example 1**
|
||||
|
||||
```js
|
||||
const parse = require('parse-git-config');
|
||||
const config = {
|
||||
'foo "bar"': { doStuff: true },
|
||||
'foo "baz"': { doStuff: true }
|
||||
};
|
||||
|
||||
console.log(parse.expandKeys(config));
|
||||
```
|
||||
|
||||
Results in:
|
||||
|
||||
```js
|
||||
{
|
||||
foo: {
|
||||
bar: { doStuff: true },
|
||||
baz: { doStuff: true }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Example 2**
|
||||
|
||||
```js
|
||||
const parse = require('parse-git-config');
|
||||
const config = {
|
||||
'remote "origin"': {
|
||||
url: 'https://github.com/jonschlinkert/normalize-pkg.git',
|
||||
fetch: '+refs/heads/*:refs/remotes/origin/*'
|
||||
},
|
||||
'branch "master"': {
|
||||
remote: 'origin',
|
||||
merge: 'refs/heads/master'
|
||||
},
|
||||
'branch "dev"': {
|
||||
remote: 'origin',
|
||||
merge: 'refs/heads/dev',
|
||||
rebase: true
|
||||
}
|
||||
};
|
||||
|
||||
console.log(parse.expandKeys(config));
|
||||
```
|
||||
|
||||
Results in:
|
||||
|
||||
```js
|
||||
{
|
||||
remote: {
|
||||
origin: {
|
||||
url: 'https://github.com/jonschlinkert/normalize-pkg.git',
|
||||
fetch: '+refs/heads/*:refs/remotes/origin/*'
|
||||
}
|
||||
},
|
||||
branch: {
|
||||
master: {
|
||||
remote: 'origin',
|
||||
merge: 'refs/heads/master'
|
||||
},
|
||||
dev: {
|
||||
remote: 'origin',
|
||||
merge: 'refs/heads/dev',
|
||||
rebase: true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
<details>
|
||||
<summary><strong>Contributing</strong></summary>
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Running Tests</strong></summary>
|
||||
|
||||
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 && npm test
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<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 -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Related projects
|
||||
|
||||
You might also be interested in these projects:
|
||||
|
||||
* [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.")
|
||||
* [parse-author](https://www.npmjs.com/package/parse-author): Parse an author, contributor, maintainer or other 'person' string into an object with name, email… [more](https://github.com/jonschlinkert/parse-author) | [homepage](https://github.com/jonschlinkert/parse-author "Parse an author, contributor, maintainer or other 'person' string into an object with name, email and url properties following npm conventions.")
|
||||
* [parse-authors](https://www.npmjs.com/package/parse-authors): Parse a string into an array of objects with `name`, `email` and `url` properties following… [more](https://github.com/jonschlinkert/parse-authors) | [homepage](https://github.com/jonschlinkert/parse-authors "Parse a string into an array of objects with `name`, `email` and `url` properties following npm conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of authors objects.")
|
||||
* [parse-github-url](https://www.npmjs.com/package/parse-github-url): Parse a github URL into an object. | [homepage](https://github.com/jonschlinkert/parse-github-url "Parse a github URL into an object.")
|
||||
* [parse-gitignore](https://www.npmjs.com/package/parse-gitignore): Parse a .gitignore or .npmignore file into an array of patterns. | [homepage](https://github.com/jonschlinkert/parse-gitignore "Parse a .gitignore or .npmignore file into an array of patterns.")
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 66 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 4 | [doowb](https://github.com/doowb) |
|
||||
| 1 | [daviwil](https://github.com/daviwil) |
|
||||
| 1 | [LexSwed](https://github.com/LexSwed) |
|
||||
| 1 | [sam3d](https://github.com/sam3d) |
|
||||
| 1 | [suarasaur](https://github.com/suarasaur) |
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||
|
||||
### 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.8.0, on November 20, 2018._
|
||||
182
node_modules/parse-git-config/index.js
generated
vendored
Normal file
182
node_modules/parse-git-config/index.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
/*!
|
||||
* parse-git-config <https://github.com/jonschlinkert/parse-git-config>
|
||||
*
|
||||
* Copyright (c) 2015-present, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const ini = require('ini');
|
||||
const configPath = require('git-config-path');
|
||||
const expand = str => (str ? str.replace(/^~/, os.homedir()) : '');
|
||||
|
||||
/**
|
||||
* Asynchronously parse a `.git/config` file. If only the callback is passed,
|
||||
* the `.git/config` file relative to `process.cwd()` is used.
|
||||
*
|
||||
* ```js
|
||||
* parse((err, config) => {
|
||||
* if (err) throw err;
|
||||
* // do stuff with config
|
||||
* });
|
||||
*
|
||||
* // or, using async/await
|
||||
* (async () => {
|
||||
* console.log(await parse());
|
||||
* console.log(await parse({ cwd: 'foo' }));
|
||||
* console.log(await parse({ cwd: 'foo', path: 'some/.git/config' }));
|
||||
* })();
|
||||
* ```
|
||||
* @name parse
|
||||
* @param {Object|String|Function} `options` Options with `cwd` or `path`, the cwd to use, or the callback function.
|
||||
* @param {Function} `callback` callback function if the first argument is options or cwd.
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
const parse = (options, callback) => {
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = null;
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
return parse.promise(options);
|
||||
}
|
||||
|
||||
return parse.promise(options)
|
||||
.then(config => callback(null, config))
|
||||
.catch(callback);
|
||||
};
|
||||
|
||||
parse.promise = options => {
|
||||
let filepath = parse.resolveConfigPath(options);
|
||||
let read = util.promisify(fs.readFile);
|
||||
let stat = util.promisify(fs.stat);
|
||||
if (!filepath) return Promise.resolve(null);
|
||||
|
||||
return stat(filepath)
|
||||
.then(() => read(filepath, 'utf8'))
|
||||
.then(str => {
|
||||
if (options && options.include === true) {
|
||||
str = injectInclude(str, path.resolve(path.dirname(filepath)));
|
||||
}
|
||||
return parseIni(str, options);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Synchronously parse a `.git/config` file. If no arguments are passed,
|
||||
* the `.git/config` file relative to `process.cwd()` is used.
|
||||
*
|
||||
* ```js
|
||||
* console.log(parse.sync());
|
||||
* console.log(parse.sync({ cwd: 'foo' }));
|
||||
* console.log(parse.sync({ cwd: 'foo', path: 'some/.git/config' }));
|
||||
* ```
|
||||
* @name .sync
|
||||
* @param {Object|String} `options` Options with `cwd` or `path`, or the cwd to use.
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
parse.sync = options => {
|
||||
let filepath = parse.resolveConfigPath(options);
|
||||
|
||||
if (filepath && fs.existsSync(filepath)) {
|
||||
let input = fs.readFileSync(filepath, 'utf8');
|
||||
if (options && options.include === true) {
|
||||
let cwd = path.resolve(path.dirname(filepath));
|
||||
input = injectInclude(input, cwd);
|
||||
}
|
||||
return parseIni(input, options);
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolve the git config path
|
||||
*/
|
||||
|
||||
parse.resolveConfigPath = options => {
|
||||
if (typeof options === 'string') options = { type: options };
|
||||
const opts = Object.assign({ cwd: process.cwd() }, options);
|
||||
const fp = opts.path ? expand(opts.path) : configPath(opts.type);
|
||||
return fp ? path.resolve(opts.cwd, fp) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deprecated: use `.resolveConfigPath` instead
|
||||
*/
|
||||
|
||||
parse.resolve = options => parse.resolveConfigPath(options);
|
||||
|
||||
/**
|
||||
* Returns an object with only the properties that had ini-style keys
|
||||
* converted to objects.
|
||||
*
|
||||
* ```js
|
||||
* const config = parse.sync({ path: '/path/to/.gitconfig' });
|
||||
* const obj = parse.expandKeys(config);
|
||||
* ```
|
||||
* @name .expandKeys
|
||||
* @param {Object} `config` The parsed git config object.
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
parse.expandKeys = config => {
|
||||
for (let key of Object.keys(config)) {
|
||||
let m = /(\S+) "(.*)"/.exec(key);
|
||||
if (!m) continue;
|
||||
let prop = m[1];
|
||||
config[prop] = config[prop] || {};
|
||||
config[prop][m[2]] = config[key];
|
||||
delete config[key];
|
||||
}
|
||||
return config;
|
||||
};
|
||||
|
||||
function parseIni(str, options) {
|
||||
let opts = Object.assign({}, options);
|
||||
|
||||
str = str.replace(/\[(\S+) "(.*)"\]/g, (m, $1, $2) => {
|
||||
return $1 && $2 ? `[${$1} "${$2.split('.').join('\\.')}"]` : m;
|
||||
});
|
||||
|
||||
let config = ini.parse(str);
|
||||
if (opts.expandKeys === true) {
|
||||
return parse.expandKeys(config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
function injectInclude(input, cwd) {
|
||||
let lines = input.split('\n').filter(line => line.trim() !== '');
|
||||
let len = lines.length;
|
||||
let res = [];
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
let line = lines[i];
|
||||
if (line.indexOf('[include]') === 0) {
|
||||
let filepath = lines[i + 1].replace(/^\s*path\s*=\s*/, '');
|
||||
let fp = path.resolve(cwd, expand(filepath));
|
||||
res.push(fs.readFileSync(fp));
|
||||
} else {
|
||||
res.push(line);
|
||||
}
|
||||
}
|
||||
return res.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `parse`
|
||||
*/
|
||||
|
||||
module.exports = parse;
|
||||
64
node_modules/parse-git-config/package.json
generated
vendored
Normal file
64
node_modules/parse-git-config/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "parse-git-config",
|
||||
"description": "Parse `.git/config` into a JavaScript object. sync or async.",
|
||||
"version": "3.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/parse-git-config",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"j. suárez (http://suarez.systems)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Sam Holmes (https://samholmes.net)"
|
||||
],
|
||||
"repository": "jonschlinkert/parse-git-config",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/parse-git-config/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"git-config-path": "^2.0.0",
|
||||
"ini": "^1.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^2.0.0",
|
||||
"mocha": "^5.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"config",
|
||||
"git",
|
||||
"parse"
|
||||
],
|
||||
"verb": {
|
||||
"run": true,
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"git-user-name",
|
||||
"git-username",
|
||||
"parse-author",
|
||||
"parse-authors",
|
||||
"parse-github-url",
|
||||
"parse-gitignore"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user