Skip to content

Install-NerdFont: follow-ups from PR #77 review (variant-aware skip, -WhatIf semantics, download robustness, cache path) #78

@MariusStorhaug

Description

Install-NerdFont: follow-ups from PR #77 review

These are valid concerns raised by reviewers on #77 that were out of scope for the perf iteration cycle and are tracked here for a follow-up PR. The perf work in #77 delivered the measured wins (Single −53 %, Subset −40 %, AlreadyInstalled −99 %); this issue captures the correctness/robustness polish layered on top.

Tasks

  • Variant-aware skip-installed shortcut. Today the skip check matches $family -like "$fontName*", so Install-NerdFont -Name Hack -Variant Mono skips when any Hack family (e.g. standard or Propo) is installed even if the Mono files are absent. Either include the requested variant in the match, or only apply the shortcut when -Variant All.
  • Tighten -Variant Mono test. The current test asserts only that some Hack font is installed. Add assertions that only Mono families/files are present and Standard/Propo variants are absent.
  • Unit tests for skip-installed and dedup paths. Mock Get-Font and the download call to assert that (a) an already-installed family skips the network call without -Force, (b) -Force still downloads, and (c) overlapping -Name inputs (wildcard + exact) download/install the matching font only once.
  • -WhatIf semantics. Several new paths regress -WhatIf:
    • Cache-hit copy runs without a ShouldProcess check, so -WhatIf still copies the cached zip into temp.
    • Downloads are queued before ShouldProcess, so -WhatIf still opens HTTP connections and may write cache files.
    • Variant filtering walks $extractPath even when extraction was skipped, producing errors under -WhatIf.
      Gate each of these on the existing ShouldProcess decisions, or include them under the same approved operation block.
  • Download retries. Switching from Invoke-WebRequest -RetryIntervalSec 5 -MaximumRetryCount 5 to raw HttpClient.GetByteArrayAsync removed the existing retry behaviour for transient CDN/GitHub errors. Add an equivalent retry loop around each HTTP request.
  • Per-font extraction error handling. ZipFile.ExtractToDirectory throws a terminating exception for corrupt archives or invalid entries, aborting the entire batch. Wrap per-font extraction in try/catch, report the failing font, and continue.
  • Bounded streaming for -All. Each download buffers the whole archive into memory via GetByteArrayAsync. With -All that can mean hundreds of MB resident. Stream each response directly to disk while keeping the existing throttle of 8.
  • Cache root platform conventions. macOS currently uses $HOME/.cache/PSModule/NerdFonts instead of $HOME/Library/Caches/PSModule/NerdFonts, and Linux ignores $Env:XDG_CACHE_HOME. Branch on $IsMacOS and $Env:XDG_CACHE_HOME when constructing the cache root.
  • Perf harness Subset-AlreadyInstalled precondition. If the preceding Subset install fails, the Subset-AlreadyInstalled scenario silently measures a cold install. Make the setup explicitly ensure the subset is installed (or skip the scenario) instead of relying on the previous run.

Origin

Raised across review comments on #77; deferred from that PR because the iteration cycle and prerelease measurements were already complete and these items belong to a separate review-able change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions