Skip to content

Commit

Permalink
feat(prompt): Add unambiguous exports
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Dec 10, 2020
1 parent 81a591c commit 46fa111
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
8 changes: 7 additions & 1 deletion commands/__mocks__/@lerna/prompt.js
Expand Up @@ -15,6 +15,10 @@ const mockSelect = jest.fn((_, { choices }) => {
});
const mockInput = jest.fn(() => Promise.resolve());

exports.promptConfirmation = mockConfirm;
exports.promptSelectOne = mockSelect;
exports.promptTextInput = mockInput;

exports.confirm = mockConfirm;
exports.select = mockSelect;
exports.input = mockInput;
Expand All @@ -32,6 +36,8 @@ const semverIndex = new Map(
].map((keyword, idx) => [keyword, idx])
);

exports.mockChoices = (...keywords) => {
exports.mockPromptChoices = (...keywords) => {
choiceIndices = keywords.map((keyword) => semverIndex.get(keyword));
};

exports.mockChoices = exports.mockPromptChoices;
19 changes: 13 additions & 6 deletions core/prompt/index.js
Expand Up @@ -3,16 +3,23 @@
const inquirer = require("inquirer");
const log = require("npmlog");

exports.confirm = confirm;
exports.select = select;
exports.input = input;
exports.promptConfirmation = promptConfirmation;
exports.promptSelectOne = promptSelectOne;
exports.promptTextInput = promptTextInput;

/** @deprecated */
exports.confirm = exports.promptConfirmation;
/** @deprecated */
exports.select = exports.promptSelectOne;
/** @deprecated */
exports.input = exports.promptTextInput;

/**
* Prompt for confirmation
* @param {string} message
* @returns {Promise<boolean>}
*/
function confirm(message) {
function promptConfirmation(message) {
log.pause();

return inquirer
Expand Down Expand Up @@ -41,7 +48,7 @@ function confirm(message) {
* @param {{ choices: import("inquirer").ListChoiceOptions[] } & Pick<import("inquirer").Question, 'filter' | 'validate'>} [options]
* @returns {Promise<string>}
*/
function select(message, { choices, filter, validate } = {}) {
function promptSelectOne(message, { choices, filter, validate } = {}) {
log.pause();

return inquirer
Expand Down Expand Up @@ -69,7 +76,7 @@ function select(message, { choices, filter, validate } = {}) {
* @param {Pick<import("inquirer").Question, 'filter' | 'validate'>} [options]
* @returns {Promise<string>}
*/
function input(message, { filter, validate } = {}) {
function promptTextInput(message, { filter, validate } = {}) {
log.pause();

return inquirer
Expand Down

0 comments on commit 46fa111

Please sign in to comment.