import { Progress } from 'vscode' ; import { AzureWizardExecuteStep } from 'vscode-azureextensionui' ; import { localSettingsFileName } from '../../../constants' ; import { setLocalAppSetting } from '../../../funcConfig/local.settings' ; import { localize } from '../../../localize' ; import { IBindingSetting } from '../../../templates/IBindingTemplate' ; import { nonNullProp , nonNullValue } from '../../../utils/nonNull' ; import { getBindingSetting } from '../../createFunction/IFunctionWizardContext' ; import { IBindingWizardContext } from '../IBindingWizardContext' ; export class LocalAppSettingCreateStep extends AzureWizardExecuteStep < IBindingWizardContext > { public priority : number = 210 ; private readonly _setting : IBindingSetting ; private readonly _valueKey : string ; constructor ( setting , valueKey ) { super ( ) ; this . _setting = setting ; this . _valueKey = valueKey ; } public async execute ( context , progress ) { progress . report ( { message : localize ( 'updatingLocalSettings' , 'Updating {0}...' , localSettingsFileName ) } ) ; const appSettingName = String ( nonNullValue ( getBindingSetting ( context , this . _setting ) , this . _setting . name ) ) ; await setLocalAppSetting ( context , context . projectPath , appSettingName , nonNullProp ( context , < any > this . _valueKey ) ) ; } public shouldExecute ( context ) { return ! ! context [ this . _valueKey ] ; } }