-
Notifications
You must be signed in to change notification settings - Fork 251
/
behave.ps1
57 lines (48 loc) · 1002 Bytes
/
behave.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$BaseDir = $PSScriptRoot
$ReInitFlag = "reinit"
$OldPath = $Env:Path
$Env:Path += ";$Env:AppData\Python\Python310\Scripts"
function Command-Available {
param($Command)
$OldPref = $ErrorActionPreference
$ErrorActionPreference = 'stop'
try {
(Get-Command $Command)
return $True
}
catch {
return $False
}
finally {
$ErrorActionPreference = $OldPref
}
}
function Env-Exists {
pipenv --venv 2>&1 | Out-Null
$?
}
# ensure pipenv available
if (!(Command-Available pipenv)) {
"installing 'pipenv'"
pip3 install pipenv --user
}
try {
# set working dir
Push-Location $BaseDir
# initialize framework if requested
if (Test-Path $ReInitFlag) {
"reinitializing"
pipenv --rm
Remove-Item $ReInitFlag
}
if (!(Env-Exists)) {
"installing env"
pipenv sync
}
# run samples
pipenv run behave $Args
}
finally {
Pop-Location
$Env:Path = $OldPath
}