mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-17 15:53:38 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
44
node_modules/gitconfiglocal/index.js
generated
vendored
Normal file
44
node_modules/gitconfiglocal/index.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
var fs = require('fs');
|
||||
var ini = require('ini');
|
||||
var path = require('path');
|
||||
|
||||
|
||||
module.exports = function(dir,cb){
|
||||
findGit(dir,function(config) {
|
||||
if(!config) return cb(new Error('no gitconfig to be found at '+dir))
|
||||
fs.readFile(config,function(err,data){
|
||||
if(err) return cb(err);
|
||||
try{
|
||||
var formatted = format(ini.parse(data.toString()));
|
||||
} catch (e){
|
||||
return cb(e);
|
||||
}
|
||||
cb(false,formatted);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function format(data){
|
||||
var out = {};
|
||||
Object.keys(data).forEach(function(k){
|
||||
if(k.indexOf('"')> -1) {
|
||||
var parts = k.split('"');
|
||||
var parentKey = parts.shift().trim();
|
||||
var childKey = parts.shift().trim();
|
||||
if(!out[parentKey]) out[parentKey] = {};
|
||||
out[parentKey][childKey] = data[k];
|
||||
} else {
|
||||
out[k] = data[k];
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function findGit(dir, cb) {
|
||||
var folder = path.join(dir, '.git/config')
|
||||
fs.exists(folder,function(exists) {
|
||||
if(exists) return cb(folder)
|
||||
if(dir === path.resolve(dir, '..')) return cb(false)
|
||||
findGit(path.resolve(dir, '..'), cb)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user