Private/GetInferredManifest.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using namespace Microsoft.PowerShell.EditorServices.Extensions

function GetInferredManifest {
    [CmdletBinding()]
    param()
    end {
        $manifestPath = ResolveRelativePath (GetSettings).SourceManifestPath
        if (-not $manifestPath -or -not (Test-Path $manifestPath)) {
            ThrowError -Exception ([IO.InvalidDataException]::new($Strings.InvalidManifestSetting)) `
                       -Id        InvalidManifestSetting `
                       -Category  InvalidDataException `
                       -Target    $manifestPath
        }
        $data = Import-LocalizedData -BaseDirectory (Split-Path $manifestPath) `
                                     -FileName      (Split-Path -Leaf $manifestPath)
        $null = $data.Add('Name', ((Split-Path $manifestPath -Leaf) -replace '.psd1$'))
        return $data
    }
}