Skip to content

Commit 70d0b74

Browse files
Handle user canceling the input
1 parent 6ecde4a commit 70d0b74

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/lldebugger.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,35 @@ async function run() {
104104
Logger.verbose('No infrastructure changes required.');
105105
} else {
106106
// list all changes and ask for approval
107-
const confirn = await inquirer.prompt([
108-
{
109-
type: 'confirm',
110-
name: 'approval',
111-
message: `\nThe following changes will be applied to your AWS account:${
112-
(changes.deployLayer
113-
? `\n - Deploy Lambda Live Debugger layer version ${version}`
114-
: '') +
115-
(changes.lambdasToUpdate.length
116-
? `\n - Attach the layer and add environment variables to the Lambdas:\n${changes.lambdasToUpdate
117-
.map((l) => ` - ${l}`)
118-
.join('\n')}`
119-
: '') +
120-
(changes.rolesToUpdate.length
121-
? `\n - Add IoT permissions to IAM Roles:\n${changes.rolesToUpdate
122-
.map((r) => ` - ${r}`)
123-
.join('\n')}`
124-
: '')
125-
}\n\nDo you want to continue?`,
126-
},
127-
]);
128-
129-
if (!confirn.approval) {
130-
Logger.log('Exiting...');
107+
try {
108+
const confirn = await inquirer.prompt([
109+
{
110+
type: 'confirm',
111+
name: 'approval',
112+
message: `\nThe following changes will be applied to your AWS account:${
113+
(changes.deployLayer
114+
? `\n - Deploy Lambda Live Debugger layer version ${version}`
115+
: '') +
116+
(changes.lambdasToUpdate.length
117+
? `\n - Attach the layer and add environment variables to the Lambdas:\n${changes.lambdasToUpdate
118+
.map((l) => ` - ${l}`)
119+
.join('\n')}`
120+
: '') +
121+
(changes.rolesToUpdate.length
122+
? `\n - Add IoT permissions to IAM Roles:\n${changes.rolesToUpdate
123+
.map((r) => ` - ${r}`)
124+
.join('\n')}`
125+
: '')
126+
}\n\nDo you want to continue?`,
127+
},
128+
]);
129+
130+
if (!confirn.approval) {
131+
Logger.log('Exiting...');
132+
return;
133+
}
134+
} catch {
135+
// user canceled
131136
return;
132137
}
133138
}

0 commit comments

Comments
 (0)