fix: FileDownload cross-platform support and target-path handling#193
Merged
Conversation
Test Results 3 files 66 suites 1m 18s ⏱️ Results for commit 0c9435b. ♻️ This comment has been updated with latest results. |
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.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Set PathToAdd = TargetParent in the file-extension branch so AddToPath prepends the directory, not the file itself - Return early after Write-Error when the parent directory is missing so AddToPath and subsequent steps are not reached with Path unset - Guard New-Item directory creation behind Install action so Test runs do not mutate the filesystem - Fix CHANGELOG wording to include 'windows' in the platform list Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a49a26c to
d1da0db
Compare
…ontainers Copilot review identified that the extension-only heuristic broke extensionless file targets common on macOS/Linux (e.g. /usr/local/bin/terraform). New branching logic: - Trailing separator on Target => always a container (captured before GetUnresolvedProviderPathFromPSPath normalizes it away) - No trailing separator + (has extension OR parent already exists) => file target - Otherwise => container (created on Install) This restores backward-compatible handling of extensionless file paths while preserving the trailing-slash escape hatch for callers who want an extensionless container target. Update tests to use trailing slashes where container semantics are intended. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
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