-
Notifications
You must be signed in to change notification settings - Fork 505
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
Changed cmdlets to functions #1848
base: Dev
Are you sure you want to change the base?
Conversation
I see this causes some issues for testing, as you're using internal functions in an external unit tests. The workaround would be to use |
@PrzemyslawKlys, I totally agree that we should be hiding as much of the functions as possible. But unfortunately, we are running into some limitations/issues/whatever you want to call them: A good example here is the This is the reason that we documented the parameters as either:
If you have other ideas how we can resolve the above issues, that would be excellent! |
For the testing Pester has what is called InModuleScope - https://pester-docs.netlify.app/docs/commands/InModuleScope so exposing functions just for tests is not necessary. For "development" what I sometimes do with my modules is that I am exposing all of the functions/aliases during development using *, but "build" module for deployment with much more robust handling and merging of necessary modules. Alternatively you can always call private/internal functions using Finally - I have an even more complicated process for my own modules where my development module is built out of hundred PS1 files, or even based on multiple other modules, but once I publish it to PSGallery all that data is merged into single PSM1 file with single PSD1 file, and there's no nesting or anything. https://www.powershellgallery.com/packages/PSWriteHTML/0.0.173 -> you can see in there I have one PSD1/PSM1 and when you go to github https://github.com/EvotecIT/PSWriteHTML/blob/master/PSWriteHTML.psd1 I have defined PSSharedGoods module that is in required modules, and https://github.com/EvotecIT/PSWriteHTML/tree/master/Private many private functions that are not getting exposed - but only on the build/publish time. I guess the easiest way is to fix Pester Tests using inmodulescope, and for that internal use (if things doesn't work between nested module - haven't tested this...) use |
This PR fixes the proper exposing of functions to the user. Currently, the module exposes "cmdlets" and only some of them allow for all functions to be exposed. Those are not cmdlets but functions so we should treat them as such.
Old version example on PSGallery
I've removed at least 2 private functions which should never be exposed to the user:
From what I see there is a bunch of comments that say it's "internal" based on functionality so:
From other submodules:
Were commented out in the PSD1. Not sure if I have addressed everything correctly - please review and fix if necessary.
After reload only those are exposed:
This will improve performance and not confuse users or conflict with other modules.