🚀 [Feature]: Install only the Nerd Font variants you need with faster reruns#77
🚀 [Feature]: Install only the Nerd Font variants you need with faster reruns#77Marius Storhaug (MariusStorhaug) wants to merge 32 commits into
Conversation
Closes #71. The progress bar adds per-byte rendering overhead that is especially expensive in non-interactive hosts. \Continue is saved and restored so the user's session is unaffected.
There was a problem hiding this comment.
Pull request overview
This PR currently implements a small Install-NerdFont download optimization by suppressing Invoke-WebRequest progress rendering, and adds a script for measuring install performance scenarios.
Changes:
- Suppresses PowerShell progress output during font archive downloads while restoring the previous preference afterward.
- Adds a performance measurement script for single-font, subset, already-installed, and optional full install scenarios.
- Ignores generated performance JSONL results.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/functions/public/Install-NerdFont.ps1 |
Wraps the download call with temporary progress suppression. |
scripts/Measure-InstallPerformance.ps1 |
Adds a benchmark helper for repeatable install timing scenarios. |
.gitignore |
Excludes generated performance result output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements001 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements001 |
Closes #74. Replaces `+=` array accumulation with a generic List and deduplicates overlapping wildcards via an OrdinalIgnoreCase HashSet, so each font is downloaded, extracted, and installed at most once per invocation. Install loop moves to `end` so pipeline input is fully resolved before any I/O. Also suppresses Write-Host / unused-parameter analyzer warnings in the perf measurement script.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements002 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements002 |
Builds a HashSet of installed family names once per invocation. When -Force is not set, each font is checked against the set and skipped end-to-end (no download, no extract, no Install-Font call) if at least one installed family matches its base name. Wildcard match handles the multi-family layout of Nerd Fonts archives (e.g. 'Hack Nerd Font', 'Hack Nerd Font Mono'). Also restructure perf script call sites to splat (fixes PSUseConsistentIndentation).
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
Previous HashSet[string] constructor crashed with ArgumentNullException on a fresh runner where Get-Font returns no items. Coerce to a real string[] (empty when no fonts) before passing to the ctor.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements003 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements003 |
Replace Expand-Archive (which scans every entry through PowerShell and materializes file objects) with the direct .NET ZipFile.ExtractToDirectory call. Same behavior, much lower per-archive overhead.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements004 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements004 |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
…isolate test cache artifacts - Installed-font skip now matches 'Ubuntu Nerd Font*' instead of 'Ubuntu*' so Ubuntu no longer false-matches UbuntuMono (thread #37) - Download throttle fixed at 8 instead of ProcessorCount to keep network usage bounded on high-core CI hosts (thread #36) - Deduplication test uses a test-only cache tag and cleans up the full directory so no artifacts persist in user cache (thread #38)
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
- Cache-hit copy is now best-effort: failures fall back to download instead of proceeding with a missing/incomplete temp archive (thread r3262766745) - Cache population uses atomic temp-file + move pattern so concurrent readers never see partially-written archives (thread r3262766732) - Variant tests now assert the correct font families are present (Mono includes *Mono* fonts; Standard includes non-Mono/non-Propo fonts) rather than the overly broad 'Hack*' pattern (thread r3262766715)
Exercises the new best-effort cache-hit path: places a directory at the cached file location to force Copy-Item failure, verifies the function falls back to a fresh download and completes the install successfully.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
…che fallback cross-platform Variant tests (Mono/Standard): Convert from integration tests that depend on Get-Font finding recently installed fonts (unreliable on CI runners) to unit tests that mock Install-Font and verify the extracted font files directly. This gives stronger assertions (each file checked against variant pattern) while removing the dependency on Install-Font -Force behavior. Cache fallback test: Replace directory-as-file fixture (which does not fail Copy-Item reliably on Windows) with Mock Copy-Item + ParameterFilter. Also backup/restore any existing real cache entry so test runs never mutate user or CI state.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
…erf script uninstall prefix match
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
tests/NerdFonts.Tests.ps1:245
- This fixture also creates directories under the real user cache path when the cache root/tag path does not already exist. Although the test removes the test tag directory later, it can still leave newly-created parent cache directories behind; track and clean up directories the test creates or make the cache root injectable so the archive lives under
$TestDrive.
if (-not (Test-Path -LiteralPath $cacheTagDir)) {
$null = New-Item -ItemType Directory -Path $cacheTagDir -Force
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Install-NerdFont can now install only the Nerd Font variants you want, reuse cached archives between runs, and skip work for fonts that are already present in the requested scope. Multi-font installs also finish faster because archive downloads are batched and extraction uses the underlying .NET zip APIs directly.
New: Install only the variants you need
Use
-Variantto limit each archive to the families you actually want to register. This is useful for terminal-focused setups where only the monospace family is needed.Allremains the default, so existing scripts keep the current behavior unless they opt intoStandard,Mono, orPropo.Changed: Repeated installs reuse prior work
When a font is already installed in the requested scope and
-Forceis not used,Install-NerdFontnow skips the download, extraction, and install phases for that font. Downloaded archives are cached per Nerd Fonts release, so retries and overlapping reruns can reuse the same zip instead of fetching it again.Changed: Multi-font installs complete faster
Bulk installs now resolve the target font set once, avoid duplicate work from overlapping name patterns, download archives in bounded batches, and extract them with
System.IO.Compression.ZipFile. The end result is less waiting during-Alland other multi-font runs without changing the default install surface.Technical Details
Install-NerdFontnow deduplicates the resolved font list, skips already-installed fonts without-Force, caches archives under the user cache directory, downloads uncached archives throughSystem.Net.Http.HttpClient, extracts withSystem.IO.Compression.ZipFile, and filters extracted files by-Variantbefore callingInstall-Font.tests/NerdFonts.Tests.ps1adds coverage for-Variant Monoinstalls.scripts/Measure-InstallPerformance.ps1adds repeatable performance scenarios for single-font, subset, rerun, and optional-Allmeasurements.README.mdnow documents variant installs, skip-on-rerun behavior, and cache bypass with-Force.