fix: FileDownload cross-platform support and target-path handling#193
Open
HeyItsGilbert wants to merge 1 commit into
Open
fix: FileDownload cross-platform support and target-path handling#193HeyItsGilbert wants to merge 1 commit into
HeyItsGilbert wants to merge 1 commit into
Conversation
#49) - Expand PSDependMap.psd1 Supports to include core/macos/linux; no Windows-only code was blocking cross-platform use (#98) - Root relative Target paths against $PWD before any path operations so callers are not burned by Split-Path against a relative string (#49) - Replace parent-exists heuristic with file-extension check to distinguish file targets from container targets; directory targets are now created when they do not yet exist rather than erroring (#49) - Fix hardcoded ";" path separator in Write-Verbose to use [IO.Path]::PathSeparator for correctness on non-Windows - Add four tests: existing-dir target, new-dir creation, extension-based file-path target, and relative target rooted against $PWD Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test Results 3 files 66 suites 1m 25s ⏱️ For more details on these failures, see this check. Results for commit bd706a2. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the FileDownload dependency type by expanding its declared platform support and by correcting how Target is interpreted (file path vs directory/container), aligning behavior with expected cross-platform and path-handling semantics.
Changes:
- Expand
FileDownloadsupport inPSDependMap.psd1to includecore,macos, andlinux. - Update
FileDownload.ps1target-path handling: normalize relative targets, distinguish file vs container targets via file extension, create missing container directories, and use the OS path separator in verbose logging. - Add Pester coverage for new directory creation, extension-based file-target branching, and
$PWD-rooting of relative targets.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| Tests/FileDownload.Type.Tests.ps1 | Adds new Pester cases covering container creation, file-target detection via extension, and relative target rooting. |
| PSDepend/PSDependScripts/FileDownload.ps1 | Implements revised target resolution and container/file branching logic; adjusts PATH verbose output separator. |
| PSDepend/PSDependMap.psd1 | Updates FileDownload platform support tags. |
| CHANGELOG.md | Documents the expanded support and target-path behavior fixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+80
to
+83
| # Normalize relative paths against $PWD so callers don't get burned by cwd-dependent splits | ||
| if (-not [IO.Path]::IsPathRooted($Target)) { | ||
| $Target = Join-Path $PWD $Target | ||
| } |
Comment on lines
+106
to
+108
| $Path = $Target | ||
| $ToInstall = $True | ||
| Write-Verbose "Target has extension, treating as file path [$Target]" |
|
|
||
| ### Added | ||
|
|
||
| - `FileDownload` is now supported on all platforms (`core`, `macos`, `linux`); there was no Windows-only code blocking this (#98). |
Comment on lines
+114
to
+116
| if (-not (Test-Path $Target)) { | ||
| New-Item -ItemType Directory -Path $Target -Force | Out-Null | ||
| } |
Comment on lines
+99
to
+104
| if (-not (Test-Path $TargetParent)) { | ||
| Write-Error "Could not find parent path [$TargetParent] for target [$Target]" | ||
| if ($PSDependAction -contains 'Test') { | ||
| return $False | ||
| } | ||
| } |
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.
Closes #98, closes #49.
Summary
PSDependMap.psd1SupportsforFileDownloadto'windows', 'core', 'macos', 'linux'— no Windows-only code was ever blocking cross-platform use.FileDownload.ps1target-path logic so directory-like targets (no extension, trailing slash) are never mistakenly treated as file paths:Targetpaths are now rooted against$PWDbefore anySplit-Path/Test-Pathcalls.parent exists + target doesn't) swapped for[IO.Path]::GetExtension($Target)— a path with an extension is a file target; everything else is a container target.New-Item -Forcerather than erroring.Write-VerbosePATH log now uses[IO.Path]::PathSeparatorinstead of a hardcoded;.Test plan
.\build.ps1 -Task StageFilesrun before testsTests/FileDownload.Type.Tests.ps1$PWD🤖 Generated with Claude Code