-
Notifications
You must be signed in to change notification settings - Fork 2
/
crank.ps1
executable file
·39 lines (30 loc) · 968 Bytes
/
crank.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env pwsh
#Requires -PSEdition Core
#Requires -Version 7
param(
[Parameter(Mandatory = $false)][string] $Scenario = "root",
[Parameter(Mandatory = $false)][string] $Profile = "local",
[Parameter(Mandatory = $false)][string] $BranchOrCommitOrTag = ""
)
$additionalArgs = @()
if (![string]::IsNullOrEmpty($BranchOrCommitOrTag)) {
$additionalArgs += "--application.source.branchOrCommit"
$additionalArgs += $BranchOrCommitOrTag
}
$repoPath = $PSScriptRoot
$config = Join-Path $repoPath "crank.yml"
if ($Windows) {
$agent = Start-Process -FilePath "crank-agent" -PassThru -WindowStyle Hidden
} else {
$agent = Start-Process -FilePath "crank-agent" -PassThru
}
Start-Sleep -Seconds 2
try {
crank --config $config --scenario $Scenario --profile $Profile $additionalArgs
}
finally {
Stop-Process -InputObject $agent -Force | Out-Null
}
if ($LASTEXITCODE -ne 0) {
throw "crank failed with exit code $LASTEXITCODE"
}