🩹 [Patch]: Update functions to take array pipeline input#6
🩹 [Patch]: Update functions to take array pipeline input#6Marius Storhaug (MariusStorhaug) merged 5 commits intomainfrom
Conversation
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
|
Please fix the linter issues: |
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
... I've fixed the trailing whitespace issues in the Base64.Tests.ps1 file. The changes have been committed in 7621f82. |
|
Lets also add:
|
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
I've added the tests you requested in 5115fc6:
I also created a small test runner script ( Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Move the code that is in tests/Run-Tests.ps1 to a BeforeAll block in the tests. |
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
I've moved the code from Run-Tests.ps1 to a BeforeAll block in the test file as requested. This keeps all the test setup code in one place and eliminates the need for a separate runner script. The BeforeAll block now imports the functions and sets up the test files. I also fixed the trailing whitespace issues that were detected by the linter. Changes are in commit de305c6. |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Base64 conversion functions to support array inputs and pipeline scenarios, and adds corresponding tests.
- Changed both
ConvertTo-Base64andConvertFrom-Base64from filters to full functions and updated theirString/Base64Stringparameters to accept string arrays. - Introduced
processblocks withforeachloops to emit one result per input element. - Expanded documentation examples for array usage and added tests covering direct, pipeline, variable, and file-based inputs.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Base64.Tests.ps1 | Added a BeforeAll setup, hard‐coded test files, and array handling tests for both functions |
| src/functions/public/ConvertTo-Base64.ps1 | Converted to a function, changed [string] $String to [string[]], and wrapped logic in a process loop |
| src/functions/public/ConvertFrom-Base64.ps1 | Converted to a function, changed [string] $Base64String to [string[]], and wrapped logic in a process loop |
Comments suppressed due to low confidence (4)
src/functions/public/ConvertTo-Base64.ps1:50
- [nitpick] The parameter name 'String' is generic and shadows the built-in String type. Consider renaming it to 'InputObject' or 'Strings' for clarity.
[string[]] $String,
src/functions/public/ConvertTo-Base64.ps1:2
- Help documentation is missing .PARAMETER blocks for the 'String' and 'Encoding' parameters. Adding these will improve automatic help and clarity.
<#
src/functions/public/ConvertFrom-Base64.ps1:51
- [nitpick] The parameter name 'Base64String' suggests a single value but accepts an array. Rename it to 'Base64Strings' or use 'InputObject' to reflect its array capability.
[string[]] $Base64String,
src/functions/public/ConvertFrom-Base64.ps1:2
- The function help lacks .PARAMETER entries for 'Base64String' and 'Encoding'. Including these sections will enhance generated help and maintain consistency.
<#
|
Module Base64 - 2.0.2 published to the PowerShell Gallery. |
|
GitHub release for Base64 v2.0.2 has been created. |
This PR updates both conversion functions (
ConvertTo-Base64andConvertFrom-Base64) to accept arrays as input, both directly and through the pipeline. These changes enable more flexible usage of the functions in PowerShell workflows that involve processing multiple values.Changes:
[string]to[string[]]to accept arraysprocessblocks withforeachloops to handle each input itemExamples:
Fixes #5.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.