Skip to content

fix: FileDownload cross-platform support and target-path handling#193

Merged
HeyItsGilbert merged 3 commits into
mainfrom
fix/filedownload-crossplatform-target-path
Jun 14, 2026
Merged

fix: FileDownload cross-platform support and target-path handling#193
HeyItsGilbert merged 3 commits into
mainfrom
fix/filedownload-crossplatform-target-path

Conversation

@HeyItsGilbert

Copy link
Copy Markdown
Member

Closes #98, closes #49.

Summary

  • Any reason FileDownload is windows only? #98: Expand PSDependMap.psd1 Supports for FileDownload to 'windows', 'core', 'macos', 'linux' — no Windows-only code was ever blocking cross-platform use.
  • FileDownload Dependency Target Path  #49: Fix FileDownload.ps1 target-path logic so directory-like targets (no extension, trailing slash) are never mistakenly treated as file paths:
    • Relative Target paths are now rooted against $PWD before any Split-Path/Test-Path calls.
    • Branch condition replaced: old heuristic (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.
    • Container targets that don't exist yet are created with New-Item -Force rather than erroring.
    • Write-Verbose PATH log now uses [IO.Path]::PathSeparator instead of a hardcoded ;.

Test plan

  • .\build.ps1 -Task StageFiles run before tests
  • All 7 tests pass in Tests/FileDownload.Type.Tests.ps1
  • New cases cover: new-directory creation, extension-based file-path branch, relative target rooted against $PWD

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 13, 2026 00:34
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

Test Results

    3 files     66 suites   1m 18s ⏱️
  975 tests   921 ✅ 54 💤 0 ❌
1 305 runs  1 241 ✅ 64 💤 0 ❌

Results for commit 0c9435b.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FileDownload support in PSDependMap.psd1 to include core, macos, and linux.
  • Update FileDownload.ps1 target-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 thread PSDepend/PSDependScripts/FileDownload.ps1 Outdated
Comment thread PSDepend/PSDependScripts/FileDownload.ps1 Outdated
Comment thread CHANGELOG.md Outdated
Comment thread PSDepend/PSDependScripts/FileDownload.ps1 Outdated
Comment thread PSDepend/PSDependScripts/FileDownload.ps1
HeyItsGilbert and others added 2 commits June 13, 2026 17:22
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>
@HeyItsGilbert HeyItsGilbert force-pushed the fix/filedownload-crossplatform-target-path branch from a49a26c to d1da0db Compare June 14, 2026 00:22
@HeyItsGilbert HeyItsGilbert requested a review from Copilot June 14, 2026 00:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread PSDepend/PSDependScripts/FileDownload.ps1 Outdated
…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>
@HeyItsGilbert HeyItsGilbert merged commit 66a85a7 into main Jun 14, 2026
7 checks passed
@HeyItsGilbert HeyItsGilbert deleted the fix/filedownload-crossplatform-target-path branch June 14, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Any reason FileDownload is windows only? FileDownload Dependency Target Path

2 participants