Merge pull request #4 from Microsoft/Update

Fixed psm1 layout for build update
This commit is contained in:
Friedrich Weinmann 2018-12-17 21:43:03 +01:00 коммит произвёл GitHub
Родитель 36050cab9c faef4d03d0
Коммит 413c8cebf1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 18 добавлений и 24 удалений

Просмотреть файл

@ -1,7 +1,8 @@
$script:ModuleRoot = $PSScriptRoot
$script:ModuleVersion = "1.0.0.0"
$script:ModuleVersion = (Import-PowerShellDataFile -Path "$($script:ModuleRoot)\PAWTools.psd1").ModuleVersion
# Detect whether at some level dotsourcing was enforced
#$script:doDotSource = Get-PSFConfigValue -FullName PAWTools.Import.DoDotSource -Fallback $false
$script:doDotSource = $false
if ($PAWTools_dotsourcemodule) { $script:doDotSource = $true }
@ -14,11 +15,13 @@ This is important when testing for paths.
#>
# Detect whether at some level loading individual module files, rather than the compiled module was enforced
#$importIndividualFiles = Get-PSFConfigValue -FullName PAWTools.Import.IndividualFiles -Fallback $false
$importIndividualFiles = $false
if ($PAWTools_importIndividualFiles) { $importIndividualFiles = $true }
if (Test-Path "$($script:ModuleRoot)\..\.git") { $importIndividualFiles = $true }
if (-not (Test-Path "$($script:ModuleRoot)\commands.ps1")) { $importIndividualFiles = $true }
#if (Test-Path (Resolve-PSFPath -Path "$($script:ModuleRoot)\..\.git" -SingleItem -NewChild)) { $importIndividualFiles = $true }
if (Test-Path -Path "$($script:ModuleRoot)\..\.git") { $importIndividualFiles = $true }
if ("<was not compiled>" -eq '<was not compiled>') { $importIndividualFiles = $true }
function Import-ModuleFile
{
<#
@ -40,7 +43,7 @@ function Import-ModuleFile
Imports the file stored in $function according to import policy
#>
[CmdletBinding()]
Param (
param (
[string]
$Path
)
@ -49,6 +52,7 @@ function Import-ModuleFile
else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText((Resolve-Path $Path)))), $null, $null) }
}
#region Load individual files
if ($importIndividualFiles)
{
# Execute Preimport actions
@ -68,18 +72,12 @@ if ($importIndividualFiles)
# Execute Postimport actions
. Import-ModuleFile -Path "$ModuleRoot\internal\scripts\postimport.ps1"
# End it here, do not load compiled code below
return
}
else
{
if (Test-Path "$($script:ModuleRoot)\resourcesBefore.ps1")
{
. Import-ModuleFile -Path "$($script:ModuleRoot)\resourcesBefore.ps1"
}
. Import-ModuleFile -Path "$($script:ModuleRoot)\commands.ps1"
if (Test-Path "$($script:ModuleRoot)\resourcesAfter.ps1")
{
. Import-ModuleFile -Path "$($script:ModuleRoot)\resourcesAfter.ps1"
}
}
#endregion Load individual files
#region Load compiled code
"<compile code into here>"
#endregion Load compiled code

Просмотреть файл

@ -1,7 +1,7 @@
Describe "Validating the module manifest" {
$moduleRoot = (Resolve-Path "$PSScriptRoot\..\..").Path
$manifest = ((Get-Content "$moduleRoot\PAWTools.psd1") -join "`n") | Invoke-Expression
[version]$moduleVersion = Get-Item "$moduleRoot\PAWTools.psm1" | Select-String -Pattern '\$script:ModuleVersion = "(.*?)"' | ForEach-Object { $_.Matches[0].Groups[1].Value }
Context "Basic resources validation" {
$files = Get-ChildItem "$moduleRoot\functions" -Recurse -File -Filter "*.ps1"
It "Exports all functions in the public folder" {
@ -18,10 +18,6 @@
$files = Get-ChildItem "$moduleRoot\internal\functions" -Recurse -File -Filter "*.ps1"
$files | Where-Object BaseName -In $manifest.FunctionsToExport | Should -BeNullOrEmpty
}
It "Has the same version as the psm1 file" {
([version]$manifest.ModuleVersion) | Should -Be $moduleVersion
}
}
Context "Individual file validation" {