Repository navigation
Conversation
The path built for -FileName was written to the output instead of being assigned to $newPath, so the command returned two paths and only created and tracked the generated file. Fixes PowershellFrameworkCollective#747
This branch has not been deployed
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.
Fixes #747
New-PSFTempFilebuilt the path for-FileNamebut never assigned it, so that path was written to the output and the command went on with the generated name. With-FileNameit returned two paths: the requested one, which was never created, and a generatedPSF_Temp_<guid>file, which was the only one created and tracked byGet-PSFTempItem.The path is now assigned to
$newPath, the same wayNew-PSFTempDirectoryhandles-DirectoryName. The command returns a single path and creates and tracks that file.Since the requested name is now actually used, an existing file with that name in the temp folder is emptied by
New-Item -Force(unchanged), andRemove-PSFTempItemdeletes it later.Testing (Windows 10):
tests/functions/temp/New-PSFTempFile.Tests.ps1, with and without-FileName. The-FileNametest fails without the fix (2 results instead of 1).tests/pester.ps1on Windows PowerShell 5.1 with Pester 6.2.0: 6492 tests, no failures. The new tests also pass on PowerShell 7.7 with Pester 5.9.1.I left
changelog.mdalone since it is written per release; happy to add an entry if you prefer.