Skip to content

Commit

Permalink
Adding PSModuleInfo get_ModuleProfiles (Fixes #273)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Sep 16, 2023
1 parent de4768e commit e2d54f6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Types/PSModuleInfo/get_ModuleProfiles.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<#
.SYNOPSIS
Gets a Module's Profiles
.DESCRIPTION
Gets the profile files associated with the module.
Any module can have a file within the same directory any valid $profile location, named `$($this.Name).profile.ps1`.
This file may be loaded when the module loads, or anytime thereafter.
#>
if (-not $profile) { return @()}
,@(@($profile.psobject.properties |
Where-Object MemberType -EQ NoteProperty |
Select-Object -ExpandProperty Value) -as [io.fileinfo[]] |
Split-Path |
Select-Object -Unique |
Where-Object { $_ } |
Join-Path -ChildPath "$($this.Name).profile.ps1" |
Where-Object { $_ | Test-Path } |
ForEach-Object { $_.FullName })

0 comments on commit e2d54f6

Please sign in to comment.