Skip to content

Commit

Permalink
Add -AsDotNetVersion option to the Get-Version script (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
flanakin authored Jan 9, 2024
1 parent 6cc7265 commit 12eb3f2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/scripts/Get-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@
Gets the current version number.
#>
return (Get-Content (Join-Path $PSScriptRoot ../../package.json) | ConvertFrom-Json).version `
param(
[switch]
$AsDotNetVersion
)

$ver = (Get-Content (Join-Path $PSScriptRoot ../../package.json) | ConvertFrom-Json).version `
-replace '^[^\d]*((\d+\.\d+)(\.\d+)?(-[a-z]+)?(\.\d+)?)[^\d]*$', '$1' `
-replace '^(\d+\.\d+)(\.\d+)?(-[a-z]+)?(\.0)?$', '$1$2$3' `
-replace '^(\d+\.\d+)(\.0)?(-[a-z]+)?(\.\d+)?$', '$1$3$4'

if ($AsDotNetVersion -and $ver.Contains('-'))
{
$arr = (($ver -replace '-[^\.0-9]+', '') -split '\.') + @(0, 0)
$arr[3] += 1000000000
return $arr[0..3] -Join '.'
}

return $ver

0 comments on commit 12eb3f2

Please sign in to comment.