functions/template-helpers/New-GitVersionConfig.ps1

# <copyright file="New-GitVersionConfig.ps1" company="Endjin Limited">
# Copyright (c) Endjin Limited. All rights reserved.
# </copyright>

<#
.SYNOPSIS
    Generates a default GitVersion confguration file.
.DESCRIPTION
    Generates a default GitVersion confguration file.
.EXAMPLE
    PS C:\> New-GitVersionConfig -Path ./GitVersion.yml
    Generates the configuration file in the current directory.
.PARAMETER Path
    The destination path for the generated file.
.PARAMETER Force
    When true, overwrites any existing file.
#>

function New-GitVersionConfig
{
    [CmdletBinding()]
    param (
        [Parameter()]
        [string] $OutputPath = "GitVersion.yml",

        [Parameter()]
        [switch] $Force
    )

    $templatePath = "$PSScriptRoot/../../templates/gitversion.tmpl.yml"

    # If we're using the default value of OutputPath (i.e. we've not specified it when calling this function),
    # then it won't be part of the PSBoundParameters collection, so we need to add it before calling the
    # underlying template helper
    if ("OutputPath" -notin $PSBoundParameters.Keys) {
        $PSBoundParameters.Add("OutputPath", $OutputPath)
    }

    _executeTemplate -TemplatePath $templatePath @PSBoundParameters
}