Private/Resolve-GhostLocalSitePath.ps1

function Resolve-GhostLocalSitePath {
    <#
    .SYNOPSIS
        Returns the full path of the folder of a local Ghost site.

    .DESCRIPTION
        Without a path that is the folder .local-ghost in the current location. A relative path is taken from
        the current location of PowerShell, which is not always the current folder of the process.

        With -ForNewSite the default is refused in the folder of a Ghost theme: Ghost reads everything in the
        folder of a theme as a part of it, and refuses a theme with a whole site in it.

    .EXAMPLE
        Resolve-GhostLocalSitePath -Path ../my-site

        Returns the full path of the folder my-site next to the current location.
    #>

    [CmdletBinding()]
    [OutputType([string])]
    param(
        # The folder of the site, when the caller named one.
        [AllowEmptyString()]
        [string] $Path,

        # The site is going to be installed when it is not there.
        [switch] $ForNewSite
    )

    $location = $ExecutionContext.SessionState.Path
    if (-not $Path) {
        $Path = '.local-ghost'

        $package = $location.GetUnresolvedProviderPathFromPSPath('package.json')
        if ($ForNewSite -and (Test-Path -LiteralPath $package -PathType Leaf)) {
            if ([System.IO.File]::ReadAllText($package) -match '"engines"\s*:\s*\{[^}]*"ghost"\s*:') {
                $advice = 'Pass -Path with a folder outside of it, such as ../my-site.'
                throw "The current location is the folder of a Ghost theme, where a site does not belong. $advice"
            }
        }
    }

    $location.GetUnresolvedProviderPathFromPSPath($Path)
}