cancelling prompts is treated as error

This commit is contained in:
Ben Irvin 2023-03-02 17:42:43 +01:00
parent a9620ba6e4
commit a1f34b312a
2 changed files with 6 additions and 4 deletions

View File

@ -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'));

View File

@ -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);
}
};
};