Skip to content

Commit 188d8b9

Browse files
Merge branch 'approval-required-option' into alpha
2 parents e3eab28 + 7929c0e commit 188d8b9

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

src/lldebugger.ts

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,41 @@ 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'
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...');
131-
return;
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 (error: any) {
135+
if (error.name === 'ExitPromptError') {
136+
// user canceled the prompt
137+
Logger.log('Exiting...');
138+
return;
139+
} else {
140+
throw error;
141+
}
132142
}
133143
}
134144
}

0 commit comments

Comments
 (0)