Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 1bbf9a1

Browse files
max-mironovRichard Hua
authored andcommitted
Make confirmation prompt more severe on app/deployment rm (#402)
* Make the prompt defaults to 'no' if no input is entered Make the message more severe than it currently for app rm and deployment rm * Fix upper/lower-case issues * Make prompt messages consistent
1 parent f23617b commit 1bbf9a1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

cli/script/command-executor.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export var execSync = childProcess.execSync;
7272

7373
var connectionInfo: ILoginConnectionInfo;
7474

75-
export var confirm = (): Promise<boolean> => {
75+
export var confirm = (message: string = "Are you sure?"): Promise<boolean> => {
76+
message += " (y/N):";
7677
return Promise<boolean>((resolve, reject, notify): void => {
7778
prompt.message = "";
7879
prompt.delimiter = "";
@@ -82,14 +83,19 @@ export var confirm = (): Promise<boolean> => {
8283
prompt.get({
8384
properties: {
8485
response: {
85-
description: chalk.cyan("Are you sure? (Y/n):")
86+
description: chalk.cyan(message)
8687
}
8788
}
8889
}, (err: any, result: any): void => {
89-
if (!result.response || result.response === "" || result.response === "Y") {
90+
var accepted = result.response && result.response.toLowerCase() === "y";
91+
var rejected = !result.response || result.response.toLowerCase() === "n";
92+
93+
if (accepted){
9094
resolve(true);
9195
} else {
92-
if (result.response !== "n") console.log("Invalid response: \"" + result.response + "\"");
96+
if (!rejected){
97+
console.log("Invalid response: \"" + result.response + "\"");
98+
}
9399
resolve(false);
94100
}
95101
});
@@ -179,7 +185,7 @@ function appList(command: cli.IAppListCommand): Promise<void> {
179185
}
180186

181187
function appRemove(command: cli.IAppRemoveCommand): Promise<void> {
182-
return confirm()
188+
return confirm("Are you sure you want to remove this app? Note that its deployment keys will be PERMANENTLY unrecoverable.")
183189
.then((wasConfirmed: boolean): Promise<void> => {
184190
if (wasConfirmed) {
185191
return sdk.removeApp(command.appName)
@@ -337,7 +343,7 @@ export var deploymentList = (command: cli.IDeploymentListCommand, showPackage: b
337343
}
338344

339345
function deploymentRemove(command: cli.IDeploymentRemoveCommand): Promise<void> {
340-
return confirm()
346+
return confirm("Are you sure you want to remove this deployment? Note that its deployment key will be PERMANENTLY unrecoverable.")
341347
.then((wasConfirmed: boolean): Promise<void> => {
342348
if (wasConfirmed) {
343349
return sdk.removeDeployment(command.appName, command.deploymentName)

0 commit comments

Comments
 (0)