From 914cc3407229a3f929ab588cf5d935f38183ba10 Mon Sep 17 00:00:00 2001 From: Friedrich Weinmann Date: Mon, 17 Dec 2018 21:36:49 +0100 Subject: [PATCH 1/2] Fixed psm1 layout for build update --- PAWTools/PAWTools.psm1 | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/PAWTools/PAWTools.psm1 b/PAWTools/PAWTools.psm1 index 52e02c5..a4361f6 100644 --- a/PAWTools/PAWTools.psm1 +++ b/PAWTools/PAWTools.psm1 @@ -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 ("" -eq '') { $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" - } -} \ No newline at end of file +#endregion Load individual files + +#region Load compiled code +"" +#endregion Load compiled code \ No newline at end of file From faef4d03d09a4d8a8f0b3016f06c9286dd17c242 Mon Sep 17 00:00:00 2001 From: Friedrich Weinmann Date: Mon, 17 Dec 2018 21:40:41 +0100 Subject: [PATCH 2/2] Removed version comparison Test was deprecated with the latest module file update --- PAWTools/tests/general/Manifest.Tests.ps1 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/PAWTools/tests/general/Manifest.Tests.ps1 b/PAWTools/tests/general/Manifest.Tests.ps1 index 1a4de10..ed9ea62 100644 --- a/PAWTools/tests/general/Manifest.Tests.ps1 +++ b/PAWTools/tests/general/Manifest.Tests.ps1 @@ -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" {