From a1f34b312a1a4c3b896fe65a83ad04bbf19b6345 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Thu, 2 Mar 2023 17:42:43 +0100 Subject: [PATCH] cancelling prompts is treated as error --- packages/core/strapi/bin/strapi.js | 6 ++++-- packages/core/strapi/lib/commands/utils/commander.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/strapi/bin/strapi.js b/packages/core/strapi/bin/strapi.js index 72dd9f9685..c07c6fe4d5 100755 --- a/packages/core/strapi/bin/strapi.js +++ b/packages/core/strapi/bin/strapi.js @@ -342,7 +342,8 @@ program } await confirmMessage( - 'The transfer will delete all data in the remote database and media files. Are you sure you want to proceed?' + 'The transfer will delete all data in the remote database and media files. Are you sure you want to proceed?', + { failMessage: 'Transfer process aborted' } )(thisCommand); } ) @@ -450,7 +451,8 @@ program .hook( 'preAction', confirmMessage( - 'The import will delete all data in your database and media files. Are you sure you want to proceed?' + 'The import will delete all data in your database and media files. Are you sure you want to proceed?', + { failMessage: 'Import process aborted' } ) ) .action(getLocalScript('transfer/import')); diff --git a/packages/core/strapi/lib/commands/utils/commander.js b/packages/core/strapi/lib/commands/utils/commander.js index c60f572b8f..e8b36d1526 100644 --- a/packages/core/strapi/lib/commands/utils/commander.js +++ b/packages/core/strapi/lib/commands/utils/commander.js @@ -97,7 +97,7 @@ const promptEncryptionKey = async (thisCommand) => { * @param {string} message The message to confirm with user * @param {object} options Additional options */ -const confirmMessage = (message) => { +const confirmMessage = (message, { failMessage } = {}) => { return async (command) => { // if we have a force option, assume yes const opts = command.opts(); @@ -116,7 +116,7 @@ const confirmMessage = (message) => { }, ]); if (!answers.confirm) { - exitWith(1); + exitWith(1, failMessage); } }; };