Skip to content

Commit

Permalink
Print a warning if the function project root can't be found on deploy
Browse files Browse the repository at this point in the history
Inform the user that the project root could not be found instead of
throwing a generic null value error and suggest a possible cause.
  • Loading branch information
mkfrey committed Jul 19, 2023
1 parent 7ced659 commit 293a928
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import type { SiteConfigResource } from '@azure/arm-appservice';
import { IDeployContext, IDeployPaths, getDeployFsPath, getDeployNode, deploy as innerDeploy, showDeployConfirmation } from '@microsoft/vscode-azext-azureappservice';
import { DialogResponses, IActionContext, nonNullValue } from '@microsoft/vscode-azext-utils';
import { DialogResponses, IActionContext } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { CodeAction, ConnectionType, DurableBackend, DurableBackendValues, ProjectLanguage, ScmType, deploySubpathSetting, functionFilter, remoteBuildSetting } from '../../constants';
import { CodeAction, ConnectionType, DurableBackend, DurableBackendValues, ProjectLanguage, ScmType, deploySubpathSetting, functionFilter, hostFileName, remoteBuildSetting } from '../../constants';
import { ext } from '../../extensionVariables';
import { addLocalFuncTelemetry } from '../../funcCoreTools/getLocalFuncCoreToolsVersion';
import { localize } from '../../localize';
Expand Down Expand Up @@ -45,7 +45,12 @@ async function deploy(actionContext: IActionContext, arg1: vscode.Uri | string |

addLocalFuncTelemetry(actionContext, deployPaths.workspaceFolder.uri.fsPath);

const projectPath: string = nonNullValue(await tryGetFunctionProjectRoot(actionContext, deployPaths.workspaceFolder));
const projectPath: string | undefined = await tryGetFunctionProjectRoot(actionContext, deployPaths.workspaceFolder);
if (projectPath === undefined) {
const message: string = localize('functionProjectRootNotFound', 'No azure function project root could be found. This can be caused by a missing {0} file.', hostFileName);
throw new Error(message);
}

const context: IFuncDeployContext = Object.assign(actionContext, deployPaths, { action: CodeAction.Deploy, defaultAppSetting: 'defaultFunctionAppToDeploy', projectPath });
if (treeUtils.isAzExtTreeItem(arg1)) {
if (!arg1.contextValue.match(ResolvedFunctionAppResource.pickSlotContextValue) &&
Expand Down

0 comments on commit 293a928

Please sign in to comment.