11 lines
491 B
PowerShell
11 lines
491 B
PowerShell
function Set-EnvBuildNumber {
|
|
param(
|
|
[AllowEmptyString()][string]$Content,
|
|
[Parameter(Mandatory = $true)][string]$BuildNumber
|
|
)
|
|
if ($BuildNumber -notmatch '^\d+$') { throw 'Build number must contain digits only.' }
|
|
$newline = if ($Content.Contains("`r`n")) { "`r`n" } else { "`n" }
|
|
$remaining = [regex]::Replace($Content, '(?m)^[\t ]*(?:export[\t ]+)?BUILD_NUMBER[\t ]*=[^\r\n]*(?:\r?\n|$)', '')
|
|
return "BUILD_NUMBER=$BuildNumber$newline$remaining"
|
|
}
|