Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
feat: 🎸 connect new interface to commitizen
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jun 5, 2018
1 parent d1c6755 commit 3dd3c67
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 43 deletions.
59 changes: 18 additions & 41 deletions lib/createPrompter.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,32 @@
const fs = require('fs');
const createState = require('./createState');
const runInteractiveQuestions = require('./runInteractiveQuestions');
const formatCommitMessage = require('./formatCommitMessage');

// if (IS_LERNA_PROJECT) {
// const allPackages = getAllPackages().map((pkg) => pkg.name);
// const changedPackages = getChangedPackages();
//
// promptQuestions = promptQuestions.concat(createPackagesQuestion(allPackages, changedPackages));
// }

module.exports = (state) => {
const createPrompter = () => {
const prompter = {
async prompter (cz, commit) {
const answers = await runInteractiveQuestions(state);
prompter (cz, commit) {
const run = async () => {
const state = createState();

await runInteractiveQuestions(state);

// if (IS_LERNA_PROJECT) {
// const allPackages = getAllPackages().map((pkg) => pkg.name);
// const changedPackages = getChangedPackages();
//
// promptQuestions = promptQuestions.concat(createPackagesQuestion(allPackages, changedPackages));
// }
const message = formatCommitMessage(state);

const wrapOptions = {
indent: '',
trim: true,
width: MAX_LINE_WIDTH
return commit(message);
};

const emoji = config.types[answers.type].emoji;
const emojiPrefix = emoji ? emoji + ' ' : '';
const head = answers.type + ': ' + emojiPrefix + answers.subject;
const affectsLine = makeAffectsLine(answers);

// Wrap these lines at MAX_LINE_WIDTH character
const body = wrap(answers.body + affectsLine, wrapOptions);
const breaking = wrap(answers.breaking, wrapOptions);
const footer = wrap(answers.footer, wrapOptions);

let msg;

msg = head;

if (body) {
msg += '\n\n' + body;
}

if (breaking) {
msg += '\n\nBREAKING CHANGE: ' + breaking;
}

if (footer) {
msg += '\n\nIssues: ' + footer;
}

return commit(msg);
run();
}
};

return prompter;
};

module.exports = createPrompter;
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const createPrompter = require('./createPrompter');
const getConfig = require('./getConfig');

module.exports = createPrompter(getConfig());
module.exports = createPrompter();

0 comments on commit 3dd3c67

Please sign in to comment.