mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 14:14:10 +00:00
fix confirm message
This commit is contained in:
parent
2a58152861
commit
2cfcd13ed9
@ -14,7 +14,7 @@ const inquirer = require('inquirer');
|
||||
const program = new Command();
|
||||
|
||||
const packageJSON = require('../package.json');
|
||||
const { promptEncryptionKey, confirmKeyValue } = require('../lib/commands/utils/commander');
|
||||
const { promptEncryptionKey, confirmMessage } = require('../lib/commands/utils/commander');
|
||||
|
||||
const checkCwdIsStrapiApp = (name) => {
|
||||
const logErrorAndExit = () => {
|
||||
@ -326,9 +326,7 @@ program
|
||||
})
|
||||
.hook(
|
||||
'preAction',
|
||||
confirmKeyValue(
|
||||
'conflictStrategy',
|
||||
'restore',
|
||||
confirmMessage(
|
||||
"Using strategy 'restore' will delete all data in your database. Are you sure you want to proceed?"
|
||||
)
|
||||
)
|
||||
|
||||
@ -48,25 +48,19 @@ const promptEncryptionKey = async (thisCommand) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* hook: confirm that key has a value with a provided message
|
||||
* hook: require a confirmation message to be accepted
|
||||
*/
|
||||
const confirmKeyValue = (key, value, message) => {
|
||||
return async (thisCommand) => {
|
||||
const opts = thisCommand.opts();
|
||||
|
||||
if (!opts[key] || opts[key] !== value) {
|
||||
console.error(`Could not confirm key ${key}, halting operation.`);
|
||||
process.exit(1);
|
||||
}
|
||||
const confirmMessage = (message) => {
|
||||
return async () => {
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
message,
|
||||
name: `confirm_${key}`,
|
||||
name: `confirm`,
|
||||
default: false,
|
||||
},
|
||||
]);
|
||||
if (!answers[`confirm_${key}`]) {
|
||||
if (!answers.confirm) {
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
@ -75,5 +69,5 @@ const confirmKeyValue = (key, value, message) => {
|
||||
module.exports = {
|
||||
parseInputList,
|
||||
promptEncryptionKey,
|
||||
confirmKeyValue,
|
||||
confirmMessage,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user