-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconventional-commits.js
36 lines (33 loc) · 1.12 KB
/
conventional-commits.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const inquirer = require('inquirer');
const originalAdapter = require('cz-conventional-changelog');
const getPackageNames = require('./getPackageNames').getPackageNames;
const path = require('path');
const packagesPath = path.resolve(__dirname, '../packages');
const scopes = ['', ...getPackageNames(packagesPath)];
inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));
exports.prompter = function (cz, commit) {
originalAdapter.prompter(
{
...cz,
prompt: (questions) => {
const modifiedQuestions = questions.map((question) => {
if (question.name === 'scope') {
return {
...question,
type: 'autocomplete',
message: 'Select a scope or input a custom one:',
source: (answersSoFar, input = '') => {
return new Promise((resolve) => {
resolve(scopes.filter((scope) => scope.includes(input)));
});
},
};
}
return question;
});
return inquirer.prompt(modifiedQuestions);
},
},
commit
);
};