This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
forked from streamich/git-cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 connect new interface to commitizen
- Loading branch information
Showing
2 changed files
with
19 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |