import * as fse from 'fs-extra' ; import * as path from 'path' ; import { localize } from "../../../localize" ; import { IFunctionTemplate } from '../../../templates/IFunctionTemplate' ; import { nonNullProp } from '../../../utils/nonNull' ; import { FunctionNameStepBase } from '../FunctionNameStepBase' ; import { getFileExtension , IDotnetFunctionWizardContext } from './IDotnetFunctionWizardContext' ; export class DotnetFunctionNameStep extends FunctionNameStepBase < IDotnetFunctionWizardContext > { protected async getUniqueFunctionName ( context ) { const template = nonNullProp ( context , 'functionTemplate' ) ; return await this . getUniqueFsPath ( context . projectPath , template . defaultFunctionName , getFileExtension ( context ) ) ; } protected async validateFunctionNameCore ( context , name ) { if ( await fse . pathExists ( path . join ( context . projectPath , name + getFileExtension ( context ) ) ) ) { return localize ( 'existingFile' , 'A file with the name "{0}" already exists.' , name ) ; } else { return undefined ; } } }