Skip to content

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

Open
HeyItsGilbert wants to merge 1 commit into
mainfrom
fix/filedownload-crossplatform-target-path
Open

fix: FileDownload cross-platform support and target-path handling#193
HeyItsGilbert wants to merge 1 commit 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

#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>
Copilot AI review requested due to automatic review settings June 13, 2026 00:34
@github-actions

Copy link
Copy Markdown

Test Results

    3 files     66 suites   1m 25s ⏱️
  969 tests   907 ✅ 54 💤 8 ❌
1 299 runs  1 227 ✅ 64 💤 8 ❌

For more details on these failures, see this check.

Results for commit bd706a2.

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 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]"
Comment thread CHANGELOG.md

### 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
}
}
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