fix(get-winapp-path): fall back to global cache when local missing (#475)#485
Merged
fix(get-winapp-path): fall back to global cache when local missing (#475)#485
Conversation
) Previously 'winapp get-winapp-path' (without --global) would print <cwd>\.winapp even when no local .winapp existed anywhere up the directory tree, causing scripts to point at non-existent folders. Now when no local .winapp is found, the command warns and falls back to the global cache path (which is also where 'winapp install' would place packages without a local .winapp). The path is now emitted via IAnsiConsole so it is captured cleanly by the test infrastructure. Closes #475 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes winapp get-winapp-path so that when no existing local .winapp directory can be found, the command warns and falls back to the global cache path instead of returning a non-existent local path (addressing #475).
Changes:
- Add fallback logic: if the resolved local
.winapppath doesn’t exist, switch to the global cache path and emit a warning. - Change path emission to use
IAnsiConsole.WriteLineso the resolved path is printed plainly (better for script consumption and test capture). - Add new command tests covering: local exists, local missing → global fallback, and
--globalmissing → error.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/winapp-CLI/WinApp.Cli/Commands/GetWinappPathCommand.cs | Implements local-missing fallback to global and prints path via IAnsiConsole. |
| src/winapp-CLI/WinApp.Cli.Tests/GetWinappPathCommandTests.cs | Adds coverage for the new fallback behavior and existing --global error behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Build Metrics ReportBinary Sizes
Test Results✅ 783 passed, 1 skipped out of 784 tests in 402.1s (-1.4s vs. baseline) Test Coverage❌ 21.4% line coverage, 36.6% branch coverage · ✅ no change vs. baseline CLI Startup Time37ms median (x64, Updated 2026-04-21 18:10:54 UTC · commit |
Address PR #485 review feedback: - Warning previously went through ILogger.LogWarning which TextWriterLogger routes via static AnsiConsole.WriteLine -> stdout, polluting the script-consumable path output. Switch to writing the warning directly to parseResult.InvocationConfiguration.Error so stdout contains only the resolved path and \path = $(winapp get-winapp-path)\ works cleanly. - Update LocalDirectoryMissing test to actually assert the warning text is on stderr (matching the test name) and that it does NOT appear on stdout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
chiaramooney
approved these changes
Apr 21, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #475.
Previously, winapp get-winapp-path (without
--global) would print<cwd>\.winappeven when no local.winappdirectory existed anywhere up the directory tree. Build scripts that consumed the output ended up pointing at non-existent folders, since installed packages had actually landed in the global cache.Behavior change
When the resolved local
.winappdirectory does not exist, the command now:WinappDirectoryService+UiSymbols.Warning) explaining that no local.winappwas found.%USERPROFILE%\.winappby default).0and prints the global path on stdout, so scripts continue to work.When
--globalis explicitly requested but the global directory is missing, behavior is unchanged: the command still returns a non-zero exit code with an error.Repro (before fix)
After fix
Implementation notes
GetWinappPathCommandfromlogger.LogInformationtoIAnsiConsole.WriteLineso the path is the only thing on stdout and is cleanly captured by tests viaTestAnsiConsole. (Non-error log levels inTextWriterLoggeruse the staticAnsiConsole, which bypasses both the injected writer and the DIIAnsiConsole, so they aren't visible to test assertions.)GetWinappPathCommandTestswith three cases: local exists, local missing -> global fallback,--globalmissing -> error.Validation
exit 0.Closes #475