mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
Remove odd rc file formatting (fixes #11)
This commit is contained in:
parent
79473ba017
commit
cb5895dbfd
2 changed files with 22 additions and 32 deletions
|
@ -1,26 +1,26 @@
|
|||
{
|
||||
"projectOwner": "jfmengels"
|
||||
, "projectName": "all-contributors-cli"
|
||||
, "imageSize": 100
|
||||
, "commit": true
|
||||
, "contributors": [
|
||||
"projectOwner": "jfmengels",
|
||||
"projectName": "all-contributors-cli",
|
||||
"imageSize": 100,
|
||||
"commit": true,
|
||||
"contributors": [
|
||||
{
|
||||
"login": "jfmengels"
|
||||
, "name": "Jeroen Engels"
|
||||
, "avatar_url": "https://avatars.githubusercontent.com/u/3869412?v=3"
|
||||
, "profile": "https://github.com/jfmengels"
|
||||
, "contributions": [
|
||||
"code"
|
||||
, "doc"
|
||||
, "test"
|
||||
"login": "jfmengels",
|
||||
"name": "Jeroen Engels",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3869412?v=3",
|
||||
"profile": "https://github.com/jfmengels",
|
||||
"contributions": [
|
||||
"code",
|
||||
"doc",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
, {
|
||||
"login": "kentcdodds"
|
||||
, "name": "Kent C. Dodds"
|
||||
, "avatar_url": "https://avatars.githubusercontent.com/u/1500684?v=3"
|
||||
, "profile": "http://kentcdodds.com/"
|
||||
, "contributions": [
|
||||
},
|
||||
{
|
||||
"login": "kentcdodds",
|
||||
"name": "Kent C. Dodds",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1500684?v=3",
|
||||
"profile": "http://kentcdodds.com/",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -3,28 +3,18 @@
|
|||
var fs = require('fs');
|
||||
var _ = require('lodash/fp');
|
||||
|
||||
function formatCommaFirst(o) {
|
||||
return JSON.stringify(o, null, 2)
|
||||
.split(/(,\n\s+)/)
|
||||
.map(function (e, i) {
|
||||
return i % 2 ? '\n' + e.substring(4) + ', ' : e;
|
||||
})
|
||||
.join('') +
|
||||
'\n';
|
||||
}
|
||||
|
||||
function readConfig(configPath) {
|
||||
return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
||||
}
|
||||
|
||||
function writeConfig(configPath, content, cb) {
|
||||
return fs.writeFile(configPath, formatCommaFirst(content), cb);
|
||||
return fs.writeFile(configPath, JSON.stringify(content, null, 2), cb);
|
||||
}
|
||||
|
||||
function writeContributors(configPath, contributors, cb) {
|
||||
var config = readConfig(configPath);
|
||||
var content = _.assign(config, {contributors: contributors});
|
||||
return fs.writeFile(configPath, formatCommaFirst(content), cb);
|
||||
return fs.writeFile(configPath, JSON.stringify(content, null, 2), cb);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in a new issue