be3e823608
git-subtree-dir: lib/vscode git-subtree-split: e5a624b788d92b8d34d1392e4c4d9789406efe8f
24 lines
759 B
PowerShell
24 lines
759 B
PowerShell
# Taken from psake https://github.com/psake/psake
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
|
|
to see if an error occcured. If an error is detected then an exception is thrown.
|
|
This function allows you to run command-line programs without having to
|
|
explicitly check the $lastexitcode variable.
|
|
|
|
.EXAMPLE
|
|
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
|
|
#>
|
|
function Exec
|
|
{
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
|
|
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
|
|
)
|
|
& $cmd
|
|
if ($lastexitcode -ne 0) {
|
|
throw ("Exec: " + $errorMessage)
|
|
}
|
|
} |