Public/Stop-GhostLocalSite.ps1
|
function Stop-GhostLocalSite { <# .SYNOPSIS Stops a Ghost site that runs on this machine. .DESCRIPTION Stops the site that Start-GhostLocalSite started. Its content stays: the posts, the images and the account are there again when the site is started the next time. A site also stops when the machine restarts. Nothing is returned. A folder without a Ghost site in it is reported and left alone. .EXAMPLE Stop-GhostLocalSite Stops the site in the folder .local-ghost of the current location. .EXAMPLE Stop-GhostLocalSite -Path ../my-site Stops the site in the folder my-site. .LINK https://docs.ghost.org/install/local #> [CmdletBinding(SupportsShouldProcess)] [OutputType([void])] param( # Folder of the site. Defaults to .local-ghost in the current location. [Parameter(Position = 0)] [string] $Path ) try { if (-not $PSBoundParameters.ContainsKey('InformationAction')) { $InformationPreference = 'Continue' } $Path = Resolve-GhostLocalSitePath -Path $Path if (-not (Test-Path -LiteralPath (Join-Path -Path $Path -ChildPath '.ghost-cli'))) { Write-Information -MessageData "There is no Ghost site in $Path." return } if ($PSCmdlet.ShouldProcess($Path, 'Stop the local Ghost site')) { Invoke-GhostCli -Arguments 'stop', '--dir', $Path } } catch { $PSCmdlet.ThrowTerminatingError($_) } } |