Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling String and FileInfo Objects To Be Piped To Include Function #290

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

UberDoodles
Copy link
Contributor

@UberDoodles UberDoodles commented Dec 6, 2019

Description

You can now do this :

$("File1.ps1","File2.ps1") | Include
Get-ChildItem | Include

Related Issue

#289

Motivation and Context

Allows users to write slightly more concise code, rather than writing for loops.

How Has This Been Tested?

New Pester tests have been added to verify that it can accept pipeline input both in the form of strings and FileInfo objects.

I also manually tested that it was backwards compatible, and could still work with the fileNamePathToInclude parameter.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@UberDoodles UberDoodles marked this pull request as ready for review December 6, 2019 20:12
@stale
Copy link

stale bot commented Feb 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 4, 2020
@devblackops devblackops self-assigned this Feb 5, 2020
@stale stale bot removed the stale label Feb 5, 2020
@devblackops devblackops self-requested a review February 5, 2020 04:53
}

Task Test {
Assert ($(Test-Path "Function:\Test-Function1") -ne $null) "Test-Function1 is not accessible";
Copy link
Member

Choose a reason for hiding this comment

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

Test-Path will return $true/$false so no need for the $null check.

If Test-Path returns $false, you're checking if that doesn't equal $null, which it doesn't, so the assert passes when it shouldn't if the function doesn't actually exist.

You can test this by putting in a bogus function name like so:

Assert (Test-Path 'Function:\BogusFunction') 'BogusFunction is not accessible'
Assert ($(Test-Path 'Function:\BogusFunction') -ne $null) 'BogusFunction  is not accessible'

Assert (Test-Path ...) will be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... not sure what I was thinking when I wrote that. I'm guessing I intended to write "-ne $false". Should have tested my test.

Thanks; I'll get it corrected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed the fix now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants