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) {
|
2016-06-23 17:26:49 +00:00
|
|
|
return fs.writeFile(configPath, JSON.stringify(content, null, 2) + '\n', 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});
|
2016-06-23 17:26:49 +00:00
|
|
|
return writeConfig(configPath, content, 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
|
|
|
};
|