mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-29 15:44:26 +00:00
Avoid stack trace and Sentry report if user answers No to confirmation prompts
Change-type: patch Signed-off-by: Paulo Castro <paulo@balena.io>
This commit is contained in:
parent
d9b417e9e5
commit
e0e76a1aa8
17
lib/actions-oclif/env/rm.ts
vendored
17
lib/actions-oclif/env/rm.ts
vendored
@ -99,17 +99,12 @@ export default class EnvRmCmd extends Command {
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await patterns.confirm(
|
||||
options.yes || false,
|
||||
'Are you sure you want to delete the environment variable?',
|
||||
);
|
||||
} catch (err) {
|
||||
if (err.message === 'Aborted') {
|
||||
return patterns.exitWithExpectedError(err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
await patterns.confirm(
|
||||
options.yes || false,
|
||||
'Are you sure you want to delete the environment variable?',
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
|
||||
await balena.pine.delete({
|
||||
resource: options.device
|
||||
|
@ -393,6 +393,7 @@ exports.initialize =
|
||||
options.yes
|
||||
"This will erase #{answers.drive}. Are you sure?"
|
||||
"Going to erase #{answers.drive}."
|
||||
true
|
||||
)
|
||||
.return(answers.drive)
|
||||
.then(umountAsync)
|
||||
|
@ -133,6 +133,7 @@ export function confirm(
|
||||
yesOption: boolean,
|
||||
message: string,
|
||||
yesMessage?: string,
|
||||
exitIfDeclined = false,
|
||||
) {
|
||||
return Bluebird.try(function() {
|
||||
if (yesOption) {
|
||||
@ -149,7 +150,11 @@ export function confirm(
|
||||
});
|
||||
}).then(function(confirmed) {
|
||||
if (!confirmed) {
|
||||
throw new Error('Aborted');
|
||||
const err = new Error('Aborted');
|
||||
if (exitIfDeclined) {
|
||||
exitWithExpectedError(err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user