-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.build-helpers.ps1
41 lines (34 loc) · 974 Bytes
/
.build-helpers.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
function Confirm-ExitCode($code, $message)
{
if ($code -eq 0) {
Write-Build Green "Exit code is 0, continue..."
} else {
$errorMessage = "Exiting with non-zero code [$code] - $message"
Write-Build Red $errorMessage
throw $errorMessage
}
}
function New-Folder {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Scope="Function")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Scope="Function")]
param(
$folder
)
if(!(Test-Path $folder))
{
New-Item -ItemType Directory -Force -Path $folder | Out-Null
}
}
function Invoke-CleanFolder {
param(
$path
)
Remove-Item "$path/*" `
-Force `
-Recurse `
-ErrorAction SilentlyContinue
}
function Edit-ValueInFile($path, $old, $new) {
(Get-Content $path).replace( $old, $new ) `
| Set-Content $path
}