mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
30 lines
716 B
PowerShell
30 lines
716 B
PowerShell
function Ensure-Location {
|
|
<#
|
|
.SYNOPSIS
|
|
Ensures current location to be set to specified directory.
|
|
.DESCRIPTION
|
|
If specified directory exists, switch to it. Otherwise create it,
|
|
then switch.
|
|
.EXAMPLE
|
|
Ensure-Location "My-Directory"
|
|
Ensure-Location -Path "Path-To-My-Directory"
|
|
#>
|
|
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string] $Path
|
|
)
|
|
|
|
if ( ! ( Test-Path $Path ) ) {
|
|
$_Params = @{
|
|
ItemType = "Directory"
|
|
Path = ${Path}
|
|
ErrorAction = "SilentlyContinue"
|
|
}
|
|
|
|
New-Item @_Params | Set-Location
|
|
} else {
|
|
Set-Location -Path ${Path}
|
|
}
|
|
}
|