< Summary - Kestrun — Combined Coverage

Information
Class: Private.Server.Helper
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Server/Helper.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 35
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Server/Helper.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Returns modules imported by the user session.
 4
 5    .DESCRIPTION
 6        Filters the list of currently loaded modules to exclude built-in PowerShell
 7        modules, Visual Studio Code host modules and Microsoft.PowerShell.* modules.
 8        The result represents modules explicitly imported by the user or scripts.
 9#>
 10function Get-KrUserImportedModule {
 11    [CmdletBinding()]
 12    [OutputType([System.Management.Automation.PSModuleInfo])]
 13    param()
 14
 15    # ----- constants ----------------------------------------------------------
 216    $inboxRoot = [IO.Path]::GetFullPath( (Join-Path $PSHOME 'Modules') )
 17
 18    # regex fragment that matches “…\.vscode\extensions\ms-vscode.powershell…”
 119    $vsCodeRegex = [Regex]::Escape(
 20        [IO.Path]::Combine('.vscode', 'extensions', 'ms-vscode.powershell')
 21    ) -replace '\\\\', '[\\/]'   # make path-separator agnostic
 22    # -------------------------------------------------------------------------
 23
 224    Get-Module | Where-Object {
 125        $path = [IO.Path]::GetFullPath($_.ModuleBase)
 26
 127        $isInbox = $path.StartsWith($inboxRoot,
 28            $IsWindows ? 'OrdinalIgnoreCase' : 'Ordinal')
 129        $isVSCode = $path -match $vsCodeRegex
 130        $isMSPSSpace = $_.Name -like 'Microsoft.PowerShell.*'
 31
 232        -not ($isInbox -or $isVSCode -or $isMSPSSpace)
 33    }
 34}
 35

Methods/Properties

Get-KrUserImportedModule()