lib/Node.ps1

function Get-NodeJsVersionConfig {
    <#
    .SYNOPSIS
        Reads the NodeJsVersion string from the same config file used by
        Get-PathsConfig. Returns $null when the key is absent or the file
        doesn't exist - callers can then skip the nvm install step.
    #>

    [CmdletBinding()]
    param(
        [Parameter()]
        [string] $ConfigFile = $script:ConfigFilePath
    )

    if (-not $ConfigFile -or -not (Test-Path -Path $ConfigFile -PathType Leaf)) {
        return $null
    }

    try {
        $raw    = Get-Content -Path $ConfigFile -Raw -Encoding UTF8
        $parsed = $raw | ConvertFrom-Json -ErrorAction Stop
    }
    catch {
        throw "Failed to parse '$ConfigFile': $($_.Exception.Message)"
    }

    if ($null -eq $parsed) { return $null }
    if (-not $parsed.PSObject.Properties['NodeJsVersion']) { return $null }

    $value = [string]$parsed.NodeJsVersion
    if ([string]::IsNullOrWhiteSpace($value)) { return $null }
    return $value
}