Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
24
lib/vscode/build/azure-pipelines/win32/exec.ps1
Normal file
24
lib/vscode/build/azure-pipelines/win32/exec.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user