mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 09:26:42 +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
9
lib/actions-oclif/env/rm.ts
vendored
9
lib/actions-oclif/env/rm.ts
vendored
@ -99,17 +99,12 @@ export default class EnvRmCmd extends Command {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
await patterns.confirm(
|
await patterns.confirm(
|
||||||
options.yes || false,
|
options.yes || false,
|
||||||
'Are you sure you want to delete the environment variable?',
|
'Are you sure you want to delete the environment variable?',
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
} catch (err) {
|
|
||||||
if (err.message === 'Aborted') {
|
|
||||||
return patterns.exitWithExpectedError(err);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
await balena.pine.delete({
|
await balena.pine.delete({
|
||||||
resource: options.device
|
resource: options.device
|
||||||
|
@ -393,6 +393,7 @@ exports.initialize =
|
|||||||
options.yes
|
options.yes
|
||||||
"This will erase #{answers.drive}. Are you sure?"
|
"This will erase #{answers.drive}. Are you sure?"
|
||||||
"Going to erase #{answers.drive}."
|
"Going to erase #{answers.drive}."
|
||||||
|
true
|
||||||
)
|
)
|
||||||
.return(answers.drive)
|
.return(answers.drive)
|
||||||
.then(umountAsync)
|
.then(umountAsync)
|
||||||
|
@ -133,6 +133,7 @@ export function confirm(
|
|||||||
yesOption: boolean,
|
yesOption: boolean,
|
||||||
message: string,
|
message: string,
|
||||||
yesMessage?: string,
|
yesMessage?: string,
|
||||||
|
exitIfDeclined = false,
|
||||||
) {
|
) {
|
||||||
return Bluebird.try(function() {
|
return Bluebird.try(function() {
|
||||||
if (yesOption) {
|
if (yesOption) {
|
||||||
@ -149,7 +150,11 @@ export function confirm(
|
|||||||
});
|
});
|
||||||
}).then(function(confirmed) {
|
}).then(function(confirmed) {
|
||||||
if (!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