From 046c4054bbadb62fdf660e3e67b803e141b13a56 Mon Sep 17 00:00:00 2001 From: Eric Jizba Date: Fri, 8 Dec 2017 17:20:41 -0800 Subject: [PATCH] Don't ignore the cancel button Turns out it returns 'DialogResponses.cancel' instead of undefined --- src/commands/createFunction.ts | 2 +- src/utils/fs.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commands/createFunction.ts b/src/commands/createFunction.ts index 23ea1de5..447a40a4 100644 --- a/src/commands/createFunction.ts +++ b/src/commands/createFunction.ts @@ -57,7 +57,7 @@ async function validateIsFunctionApp(telemetryProperties: { [key: string]: strin const result: vscode.MessageItem | undefined = await vscode.window.showWarningMessage(message, DialogResponses.yes, DialogResponses.skipForNow, DialogResponses.cancel); if (result === DialogResponses.yes) { await createNewProject(telemetryProperties, outputChannel, functionAppPath, false, ui); - } else if (result === undefined) { + } else if (result !== DialogResponses.skipForNow) { throw new UserCancelledError(); } } diff --git a/src/utils/fs.ts b/src/utils/fs.ts index 11bb3eb4..9c61ecfa 100644 --- a/src/utils/fs.ts +++ b/src/utils/fs.ts @@ -36,10 +36,12 @@ export async function copyFolder(fromPath: string, toPath: string): Promise { if (await fse.pathExists(fsPath)) { const result: MessageItem | undefined = await vscode.window.showWarningMessage(localize('azFunc.fileAlreadyExists', 'File "{0}" already exists. Overwrite?', fsPath), DialogResponses.yes, DialogResponses.no, DialogResponses.cancel); - if (result === undefined) { - throw new UserCancelledError(); + if (result === DialogResponses.yes) { + return true; + } else if (result === DialogResponses.no) { + return false; } else { - return result === DialogResponses.yes; + throw new UserCancelledError(); } } else { return true;