1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-23 00:50:08 +00:00

fix(windows): stabilize install and prerelease versioning

This commit is contained in:
Tw93
2026-03-22 14:39:25 +08:00
parent 05fbc007d5
commit 16c3ea9867
13 changed files with 211 additions and 54 deletions

41
lib/core/version.ps1 Normal file
View File

@@ -0,0 +1,41 @@
# Mole - Version helpers
# Provides a single source of truth for the Windows version string.
#Requires -Version 5.1
Set-StrictMode -Version Latest
if ((Get-Variable -Name 'MOLE_VERSION_HELPERS_LOADED' -Scope Script -ErrorAction SilentlyContinue) -and $script:MOLE_VERSION_HELPERS_LOADED) {
return
}
$script:MOLE_VERSION_HELPERS_LOADED = $true
$script:MoleDefaultVersion = "1.29.0"
function Get-MoleVersionFilePath {
param([string]$RootDir)
if ([string]::IsNullOrWhiteSpace($RootDir)) {
return $null
}
return Join-Path $RootDir "VERSION"
}
function Get-MoleVersionString {
param(
[string]$RootDir,
[string]$DefaultVersion = $script:MoleDefaultVersion
)
$versionFile = Get-MoleVersionFilePath -RootDir $RootDir
if (-not $versionFile -or -not (Test-Path $versionFile)) {
return $DefaultVersion
}
$version = (Get-Content $versionFile -Raw).Trim()
if ([string]::IsNullOrWhiteSpace($version)) {
return $DefaultVersion
}
return $version
}