mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-10 05:56:29 +00:00
35 lines
973 B
JavaScript
35 lines
973 B
JavaScript
'use strict';
|
|
|
|
var _ = require('lodash/fp');
|
|
var series = require('async/series');
|
|
var util = require('../util');
|
|
var prompt = require('./prompt');
|
|
var initContent = require('./initContent');
|
|
var configFile = util.configFile;
|
|
var markdown = util.markdown;
|
|
|
|
function injectInFile(file, fn, cb) {
|
|
markdown.read(file, function (error, content) {
|
|
if (error) {
|
|
return cb(error);
|
|
}
|
|
markdown.write(file, fn(content), cb);
|
|
});
|
|
}
|
|
|
|
module.exports = function init(callback) {
|
|
prompt(function postPrompt(result) {
|
|
var tasks = [
|
|
function writeConfig(cb) {
|
|
configFile.writeConfig('.all-contributorsrc', result.config, cb);
|
|
},
|
|
function addContributorsList(cb) {
|
|
injectInFile(result.contributorFile, initContent.addContributorsList, cb);
|
|
},
|
|
result.badgeFile && function addBadge(cb) {
|
|
injectInFile(result.badgeFile, initContent.addBadge, cb);
|
|
}
|
|
];
|
|
series(_.compact(tasks), callback);
|
|
});
|
|
};
|