all-contributors-cli/lib/init/index.js
Jeroen Engels 1305a7cd92 fix: Bump inquirer to v3 and promisify everything (#34)
BREAKING CHANGE: Drop support for Node < v4. This uses native Promises available from Node v4.

* fix: Bump inquirer to v3.0.1. Fixes #33 to improve Windows support.

* refactor: Promisify everything as inquirer uses Promises from 1.0.0 onwards
2017-02-15 22:25:32 +01:00

25 lines
703 B
JavaScript

'use strict';
var util = require('../util');
var prompt = require('./prompt');
var initContent = require('./init-content');
var configFile = util.configFile;
var markdown = util.markdown;
function injectInFile(file, fn) {
return markdown.read(file)
.then(content => markdown.write(file, fn(content)));
}
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);
}
});
});
};