Dot-source script files in a module vs. importing via the manifest

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Joel Newton Joel Newton 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34640
    Profile photo of Joel Newton
    Joel Newton
    Participant

    I have a rather large custom module that I've made available on github. I've had a few requests to extract the functions into individual .PS1 files that are then loaded by the .PSM1 file. Is this something that can be handled via telling the manifest to include/import all .PS1 files located in specific folders, or will I need to put the logic for dot-sourcing the PS1 files into the .PSM1 file?

    #34641
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    I tend to dot-source. Particularly for the scenario you describe (just load everything in the folder), it's easier to just use Get-ChildItem and a foreach loop.

    #34650
    Profile photo of Don Jones
    Don Jones
    Keymaster

    You could also create a manifest for the module, and have it import all of them when the module is loaded. But, as Dave implies, you have to explicitly list them all – there's no so much a wildcard option that way.

    #34663
    Profile photo of Joel Newton
    Joel Newton
    Participant

    Thanks, guys. So until manifests are able to accept wildcards, sounds like I'll be sticking with dot-sourcing. Cheers.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.