commit
7812606e64
@ -0,0 +1,17 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[test/fixtures/*]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
@ -0,0 +1 @@
|
||||
*.* text eol=lf
|
@ -0,0 +1,12 @@
|
||||
*.DS_store
|
||||
*.sublime-*
|
||||
_gh_pages
|
||||
bower_components
|
||||
node_modules
|
||||
npm-debug.log
|
||||
actual
|
||||
test/actual
|
||||
temp
|
||||
tmp
|
||||
TODO.md
|
||||
vendor
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"asi": false,
|
||||
"boss": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"esnext": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"laxcomma": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"node": true,
|
||||
"sub": true,
|
||||
"undef": "var",
|
||||
"unused": true,
|
||||
"mocha": true
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
# {%= name %} {%= badge("fury") %}
|
||||
|
||||
> {%= description %}
|
||||
|
||||
{%= include("install-npm", {save: true}) %}
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var parseGitConfig = require('{%= name %}');
|
||||
```
|
||||
|
||||
## API
|
||||
{%= apidocs("index.js") %}
|
||||
|
||||
|
||||
## 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]({%= bugs.url %})
|
||||
|
||||
## Author
|
||||
{%= include("author") %}
|
||||
|
||||
## License
|
||||
{%= copyright() %}
|
||||
{%= license() %}
|
||||
|
||||
***
|
||||
|
||||
{%= include("footer") %}
|
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 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.
|
@ -0,0 +1,52 @@
|
||||
/*!
|
||||
* parse-git-config <https://github.com/jonschlinkert/parse-git-config>
|
||||
*
|
||||
* Copyright (c) 2015 Jon Schlinkert.
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var ini = require('ini');
|
||||
var lookup = require('look-up');
|
||||
|
||||
module.exports = config;
|
||||
|
||||
function config(cwd, cb) {
|
||||
if (typeof cwd === 'function') {
|
||||
cb = cwd; cwd = null;
|
||||
}
|
||||
|
||||
var fp = path.join(cwd || process.cwd(), '.git/config');
|
||||
read(fp, function (err, buffer) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = ini.parse(buffer.toString());
|
||||
return cb(null, data);
|
||||
});
|
||||
}
|
||||
|
||||
config.sync = function configSync(cwd) {
|
||||
var fp = path.join(cwd || process.cwd(), '.git/config');
|
||||
if (!fs.existsSync(fp)) {
|
||||
throw new Error('.git/config does not exist.');
|
||||
}
|
||||
return ini.parse(fs.readFileSync(fp, 'utf8'));
|
||||
};
|
||||
|
||||
function read(fp, cb) {
|
||||
try {
|
||||
fs.readFile(fp, function (err, data) {
|
||||
if (err) return cb(err);
|
||||
|
||||
return cb(null, data);
|
||||
});
|
||||
} catch (err) {
|
||||
cb(err);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "parse-git-config",
|
||||
"description": "Parse .git/config into a JavaScript object.",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://github.com/jonschlinkert/parse-git-config",
|
||||
"author": {
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/jonschlinkert"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jonschlinkert/parse-git-config.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/parse-git-config/issues"
|
||||
},
|
||||
"license": {
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/jonschlinkert/parse-git-config/blob/master/LICENSE"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"ini": "^1.3.3",
|
||||
"look-up": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"keywords": []
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*!
|
||||
* parse-git-config <https://github.com/jonschlinkert/parse-git-config>
|
||||
*
|
||||
* Copyright (c) 2015 Jon Schlinkert.
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var should = require('should');
|
||||
var config = require('./');
|
||||
|
||||
describe('sync:', function () {
|
||||
it('should return an object', function () {
|
||||
config.sync().should.have.properties([]);
|
||||
});
|
||||
|
||||
it('should throw an error when .git/config does not exist:', function () {
|
||||
(function () {
|
||||
config.sync('foo');
|
||||
}).should.throw('.git/config does not exist.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('async:', function () {
|
||||
it('should throw an error when .git/config does not exist:', function (cb) {
|
||||
config(function (err, data) {
|
||||
console.log(arguments)
|
||||
});
|
||||
cb();
|
||||
});
|
||||
|
||||
it('should throw an error when .git/config does not exist:', function (cb) {
|
||||
config('foo', function (err, data) {
|
||||
console.log(arguments)
|
||||
});
|
||||
cb();
|
||||
});
|
||||
});
|
Loading…
Reference in new issue