all-contributors-cli/lib/init/index.js

26 lines
703 B
JavaScript
Raw Normal View History

2016-03-21 21:40:32 +00:00
'use strict';
2016-03-27 15:08:25 +00:00
var util = require('../util');
2016-03-21 21:40:32 +00:00
var prompt = require('./prompt');
2016-05-05 14:27:26 +00:00
var initContent = require('./init-content');
2016-03-27 15:08:25 +00:00
var configFile = util.configFile;
var markdown = util.markdown;
2016-03-21 22:53:02 +00:00
function injectInFile(file, fn) {
return markdown.read(file)
.then(content => markdown.write(file, fn(content)));
2016-03-21 22:53:02 +00:00
}
2016-03-21 21:40:32 +00:00
module.exports = function init() {
return prompt()
.then(result => {
return configFile.writeConfig('.all-contributorsrc', result.config)
.then(() => injectInFile(result.contributorFile, initContent.addContributorsList))
.then(() => {
if (result.badgeFile) {
return injectInFile(result.badgeFile, initContent.addBadge);
}
});
});
2016-03-21 21:40:32 +00:00
};