guld-git-config-ini
A git config ini encoder/decoder for guld
Install
Node
npm i guld-git-config-ini
Browser
curl https///bitbucket.org/guld/tech-js-node_modules-guld-git-config-ini/raw/guld/ini.min.js -o ini.min.js
Usage
Consider an git config ini-file .git/config
that looks like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/nfer/git-config-ini
fetch = +refs/heads/*:refs/remotes/origin/*
[user]
name = Nfer Zhuang
You can read, manipulate and write the ini-file like so:
var fs = require('fs')
, ini = require('ini')
var config = ini.parse(fs.readFileSync('.git/config', 'utf-8'))
config.core.filemode = false
config.user.name = 'nfer'
config.user.email = 'nfer@nferzhuang.com'
fs.writeFileSync('.git/config', ini.stringify(config))
Browser
This script has been bundled for browser use and is available as global var gitConfigIni
.
<html>
<body>
<script src="ini.min.js"></script>
<script>
console.log(gitConfigIni)
</script>
</body>
</html>
API
decode(inistring)
Decode the ini-style formatted inistring
into a nested object.
parse(inistring)
Alias for decode(inistring)
encode(object)
Encode the object object
into an ini-style formatted string.
stringify(object)
Alias for encode(object)
License
MIT Copyright Nfer Zhuang nfer.zhuang@gmail.com