all-contributors-cli/lib/util/config-file.js

25 lines
643 B
JavaScript
Raw Normal View History

2016-03-02 22:45:23 +00:00
'use strict';
var fs = require('fs');
var _ = require('lodash/fp');
function readConfig(configPath) {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
}
2016-03-21 21:40:32 +00:00
function writeConfig(configPath, content, cb) {
return fs.writeFile(configPath, JSON.stringify(content, null, 2), cb);
2016-03-21 21:40:32 +00:00
}
2016-03-02 22:45:23 +00:00
function writeContributors(configPath, contributors, cb) {
var config = readConfig(configPath);
2016-03-06 23:20:24 +00:00
var content = _.assign(config, {contributors: contributors});
return fs.writeFile(configPath, JSON.stringify(content, null, 2), cb);
2016-03-02 22:45:23 +00:00
}
module.exports = {
readConfig: readConfig,
2016-03-21 21:40:32 +00:00
writeConfig: writeConfig,
2016-03-02 22:45:23 +00:00
writeContributors: writeContributors
2016-03-06 23:20:24 +00:00
};