diff --git a/.vscode/settings.json b/.vscode/settings.json index bb482c1..227163e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,9 @@ "editor.insertSpaces": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.codeFormatting.preset": "OTBS" + "powershell.codeFormatting.preset": "OTBS", + "powershell.codeFormatting.addWhitespaceAroundPipe": true, + "powershell.codeFormatting.useCorrectCasing": true, + "powershell.codeFormatting.newLineAfterOpenBrace": true, + "powershell.codeFormatting.alignPropertyValuePairs": true } diff --git a/CHANGELOG.md b/CHANGELOG.md index da0da61..511c3e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased -### Breaking Changes +### Changed - [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules are now explicitly created as UTF-8 files. - [**#67**](https://github.com/psake/PowerShellBuild/pull/67) You can now overwrite existing markdown files using `$PSBPreference.Docs.Overwrite` and setting it to `$true`. +- Loose dependencies by allowing them to be overwritten with $PSBPreference. +- [**#72**](https://github.com/psake/PowerShellBuild/pull/72) Loosen + dependencies by allowing them to be overwritten with + `$PSBPreference.TaskDependencies`. ## [0.6.2] 2024-10-06 @@ -133,13 +137,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). 'Public' folder when dot sourcing functions in PSM1 (via [@pauby](https://github.com/pauby)) -### Changed - -- [**#19**](https://github.com/psake/PowerShellBuild/pull/19) Allow the - `BHBuildOutput` environment variable defined by `BuildHelpers` to be set via - the `$PSBPreference.Build.ModuleOutDir` property of the build tasks (via - [@pauby](https://github.com/pauby)) - ### Breaking changes - Refactor build properties into a single hashtable `$PSBPreference` @@ -150,6 +147,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). tasks are now auto-generated from the psake tasks via a converter script (via [@JustinGrote](https://github.com/JustinGrote)) +- [**#19**](https://github.com/psake/PowerShellBuild/pull/19) Allow the + `BHBuildOutput` environment variable defined by `BuildHelpers` to be set via + the `$PSBPreference.Build.ModuleOutDir` property of the build tasks (via + [@pauby](https://github.com/pauby)) + ## [0.2.0] - 2018-11-15 ### Added @@ -170,3 +172,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Initial commit + +<!--spell-checker:ignore IMJLA webtroter joshooaj pauby joeypiccola nightroman --> diff --git a/PowerShellBuild/build.properties.ps1 b/PowerShellBuild/build.properties.ps1 index ba39881..15570cd 100644 --- a/PowerShellBuild/build.properties.ps1 +++ b/PowerShellBuild/build.properties.ps1 @@ -1,3 +1,4 @@ +# spell-checker:ignore PSGALLERY BHPS MAML BuildHelpers\Set-BuildEnvironment -Force $outDir = [IO.Path]::Combine($env:BHProjectPath, 'Output') @@ -22,7 +23,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul } Build = @{ - Dependencies = @('StageFiles', 'BuildHelp') + # "Dependencies" moved to TaskDependencies section # Output directory when building a module OutDir = $outDir @@ -98,7 +99,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul } } Help = @{ - # Path to updateable help CAB + # Path to updatable help CAB UpdatableHelpOutDir = [IO.Path]::Combine($outDir, 'UpdatableHelp') # Default Locale used for help generation, defaults to en-US @@ -125,6 +126,19 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul # Credential to authenticate to PowerShell repository with PSRepositoryCredential = $null } + TaskDependencies = @{ + Clean = @('Init') + StageFiles = @('Clean') + Build = @('StageFiles', 'BuildHelp') + Analyze = @('Build') + Pester = @('Build') + Test = @('Pester', 'Analyze') + BuildHelp = @('GenerateMarkdown', 'GenerateMAML') + GenerateMarkdown = @('StageFiles') + GenerateMAML = @('GenerateMarkdown') + GenerateUpdatableHelp = @('BuildHelp') + Publish = @('Test') + } } # Enable/disable generation of a catalog (.cat) file for the module. diff --git a/PowerShellBuild/psakeFile.ps1 b/PowerShellBuild/psakeFile.ps1 index 23712e8..91073e4 100644 --- a/PowerShellBuild/psakeFile.ps1 +++ b/PowerShellBuild/psakeFile.ps1 @@ -1,9 +1,9 @@ - +# spell-checker:ignore Reqs # Load in build settings Remove-Variable -Name PSBPreference -Scope Script -Force -ErrorAction Ignore Set-Variable -Name PSBPreference -Option ReadOnly -Scope Script -Value (. ([IO.Path]::Combine($PSScriptRoot, 'build.properties.ps1'))) -properties {} +Properties {} FormatTaskName { param($taskName) @@ -15,24 +15,24 @@ FormatTaskName { # Can't have two 'default' tasks # Task default -depends Test -task Init { +Task Init { Initialize-PSBuild -UseBuildHelpers -BuildEnvironment $PSBPreference } -description 'Initialize build environment variables' -task Clean -depends Init { +Task Clean -depends $PSBPreference.TaskDependencies.Clean { Clear-PSBuildOutputFolder -Path $PSBPreference.Build.ModuleOutDir } -description 'Clears module output directory' -task StageFiles -depends Clean { +Task StageFiles -depends $PSBPreference.TaskDependencies.StageFiles { $buildParams = @{ - Path = $PSBPreference.General.SrcRootDir - ModuleName = $PSBPreference.General.ModuleName - DestinationPath = $PSBPreference.Build.ModuleOutDir - Exclude = $PSBPreference.Build.Exclude - Compile = $PSBPreference.Build.CompileModule - CompileDirectories = $PSBPreference.Build.CompileDirectories - CopyDirectories = $PSBPreference.Build.CopyDirectories - Culture = $PSBPreference.Help.DefaultLocale + Path = $PSBPreference.General.SrcRootDir + ModuleName = $PSBPreference.General.ModuleName + DestinationPath = $PSBPreference.Build.ModuleOutDir + Exclude = $PSBPreference.Build.Exclude + Compile = $PSBPreference.Build.CompileModule + CompileDirectories = $PSBPreference.Build.CompileDirectories + CopyDirectories = $PSBPreference.Build.CopyDirectories + Culture = $PSBPreference.Help.DefaultLocale } if ($PSBPreference.Help.ConvertReadMeToAboutHelp) { @@ -53,7 +53,7 @@ task StageFiles -depends Clean { Build-PSBuildModule @buildParams } -description 'Builds module based on source directory' -task Build -depends $PSBPreference.Build.Dependencies -description 'Builds module and generate help documentation' +Task Build -depends $PSBPreference.TaskDependencies.Build -description 'Builds module and generate help documentation' $analyzePreReqs = { $result = $true @@ -67,7 +67,7 @@ $analyzePreReqs = { } $result } -task Analyze -depends Build -precondition $analyzePreReqs { +Task Analyze -depends $PSBPreference.TaskDependencies.Analyze -precondition $analyzePreReqs { $analyzeParams = @{ Path = $PSBPreference.Build.ModuleOutDir SeverityThreshold = $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel @@ -92,7 +92,7 @@ $pesterPreReqs = { } return $result } -task Pester -depends Build -precondition $pesterPreReqs { +Task Pester -depends $PSBPreference.TaskDependencies.Pester -precondition $pesterPreReqs { $pesterParams = @{ Path = $PSBPreference.Test.RootDir ModuleName = $PSBPreference.General.ModuleName @@ -109,10 +109,10 @@ task Pester -depends Build -precondition $pesterPreReqs { Test-PSBuildPester @pesterParams } -description 'Execute Pester tests' -task Test -depends Pester, Analyze { +Task Test -depends $PSBPreference.TaskDependencies.Test { } -description 'Execute Pester and ScriptAnalyzer tests' -task BuildHelp -depends GenerateMarkdown, GenerateMAML {} -description 'Builds help documentation' +Task BuildHelp -depends $PSBPreference.TaskDependencies.BuildHelp {} -description 'Builds help documentation' $genMarkdownPreReqs = { $result = $true @@ -122,7 +122,7 @@ $genMarkdownPreReqs = { } $result } -task GenerateMarkdown -depends StageFiles -precondition $genMarkdownPreReqs { +Task GenerateMarkdown -depends $PSBPreference.TaskDependencies.GenerateMarkdown -precondition $genMarkdownPreReqs { $buildMDParams = @{ ModulePath = $PSBPreference.Build.ModuleOutDir ModuleName = $PSBPreference.General.ModuleName @@ -141,7 +141,7 @@ $genHelpFilesPreReqs = { } $result } -task GenerateMAML -depends GenerateMarkdown -precondition $genHelpFilesPreReqs { +Task GenerateMAML -depends $PSBPreference.TaskDependencies.GenerateMAML -precondition $genHelpFilesPreReqs { Build-PSBuildMAMLHelp -Path $PSBPreference.Docs.RootDir -DestinationPath $PSBPreference.Build.ModuleOutDir } -description 'Generates MAML-based help from PlatyPS markdown files' @@ -153,11 +153,11 @@ $genUpdatableHelpPreReqs = { } $result } -task GenerateUpdatableHelp -depends BuildHelp -precondition $genUpdatableHelpPreReqs { +Task GenerateUpdatableHelp -depends $PSBPreference.TaskDependencies.GenerateUpdatableHelp -precondition $genUpdatableHelpPreReqs { Build-PSBuildUpdatableHelp -DocsPath $PSBPreference.Docs.RootDir -OutputPath $PSBPreference.Help.UpdatableHelpOutDir } -description 'Create updatable help .cab file based on PlatyPS markdown help' -task Publish -depends Test { +Task Publish -depends $PSBPreference.TaskDependencies.Publish { Assert -conditionToCheck ($PSBPreference.Publish.PSRepositoryApiKey -or $PSBPreference.Publish.PSRepositoryCredential) -failureMessage "API key or credential not defined to authenticate with [$($PSBPreference.Publish.PSRepository)] with." $publishParams = @{ @@ -177,7 +177,7 @@ task Publish -depends Test { Publish-PSBuildModule @publishParams } -description 'Publish module to the defined PowerShell repository' -task ? -description 'Lists the available tasks' { +Task ? -description 'Lists the available tasks' { 'Available tasks:' $psake.context.Peek().Tasks.Keys | Sort-Object } diff --git a/README.md b/README.md index 1909e0d..bd992f5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PowerShellBuild -| GitHub Actions | PS Gallery | License | -|----------------|------------|---------| +| GitHub Actions | PS Gallery | License | +|-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|--------------------------------------| | [![GitHub Actions Status][github-actions-badge]][github-actions-build] [![GitHub Actions Status][github-actions-badge-publish]][github-actions-build] | [![PowerShell Gallery][psgallery-badge]][psgallery] | [![License][license-badge]][license] | This project aims to provide common [psake](https://github.com/psake/psake) and @@ -53,28 +53,28 @@ other projects. These primary tasks are the main tasks you'll typically call as part of PowerShell module development. -| Name | Dependencies | Description | -| --------------------- | --------------------- | ----------- | -| Init | _none_ | Initialize psake and task variables | -| Clean | init | Clean output directory | -| Build | StageFiles, BuildHelp | Clean and build module in output directory | -| Analyze | Build | Run PSScriptAnalyzer tests | -| Pester | Build | Run Pester tests | -| Test | Analyze, Pester | Run combined tests | -| Publish | Test | Publish module to defined PowerShell repository | +| Name | Dependencies | Description | +|---------|-----------------------|-------------------------------------------------| +| Init | _none_ | Initialize psake and task variables | +| Clean | init | Clean output directory | +| Build | StageFiles, BuildHelp | Clean and build module in output directory | +| Analyze | Build | Run PSScriptAnalyzer tests | +| Pester | Build | Run Pester tests | +| Test | Analyze, Pester | Run combined tests | +| Publish | Test | Publish module to defined PowerShell repository | ### Secondary Tasks These secondary tasks are called as dependencies from the primary tasks but may also be called directly. -| Name | Dependencies | Description | -| --------------------- | -------------------------------| ----------- | -| BuildHelp | GenerateMarkdown, GenerateMAML | Build all help files | +| Name | Dependencies | Description | +|-----------------------|--------------------------------|----------------------------------| +| BuildHelp | GenerateMarkdown, GenerateMAML | Build all help files | | StageFiles | Clean | Build module in output directory | -| GenerateMarkdown | StageFiles | Build markdown-based help | -| GenerateMAML | GenerateMarkdown | Build MAML help | -| GenerateUpdatableHelp | BuildHelp | Build updatable help cab | +| GenerateMarkdown | StageFiles | Build markdown-based help | +| GenerateMAML | GenerateMarkdown | Build MAML help | +| GenerateUpdatableHelp | BuildHelp | Build updatable help cab | ## Task customization @@ -119,10 +119,21 @@ match your environment. | $PSBPreference.Help.DefaultLocale | `(Get-UICulture).Name` | Default locale used for help generation | | $PSBPreference.Help.ConvertReadMeToAboutHelp | `$false` | Convert project readme into the module about file | | $PSBPreference.Docs.RootDir | `$projectRoot/docs` | Directory PlatyPS markdown documentation will be saved to | -| $PSBPreference.Docs.Overwrite | `$false` | Overwrite the markdown files in the docs folder using the comment based help as the source of truth. | +| $PSBPreference.Docs.Overwrite | `$false` | Overwrite the markdown files in the docs folder using the comment based help as the source of truth. | | $PSBPreference.Publish.PSRepository | `PSGallery` | PowerShell repository name to publish | | $PSBPreference.Publish.PSRepositoryApiKey | `$env:PSGALLERY_API_KEY` | API key to authenticate to PowerShell repository with | | $PSBPreference.Publish.PSRepositoryCredential | `$null` | Credential to authenticate to PowerShell repository with. Overrides `$psRepositoryApiKey` if defined | +| $PSBPreference.TaskDependencies.Clean | 'Init' | Tasks the 'Clean' task depends on. | +| $PSBPreference.TaskDependencies.StageFiles | 'Clean' | Tasks the 'StageFiles' task depends on. | +| $PSBPreference.TaskDependencies.Build | 'StageFiles', 'BuildHelp' | Tasks the 'Build' task depends on. | +| $PSBPreference.TaskDependencies.Analyze | 'Build' | Tasks the 'Analyze' task depends on. | +| $PSBPreference.TaskDependencies.Pester | 'Build' | Tasks the 'Pester' task depends on. | +| $PSBPreference.TaskDependencies.Test | 'Pester', 'Analyze' | Tasks the 'Test' task depends on. | +| $PSBPreference.TaskDependencies.BuildHelp | 'GenerateMarkdown', 'GenerateMAML' | Tasks the 'BuildHelp' task depends on. | +| $PSBPreference.TaskDependencies.GenerateMarkdown | 'StageFiles' | Tasks the 'GenerateMarkdown' task depends on. | +| $PSBPreference.TaskDependencies.GenerateMAML | 'GenerateMarkdown' | Tasks the 'GenerateMAML' task depends on. | +| $PSBPreference.TaskDependencies.GenerateUpdatableHelp | 'BuildHelp' | Tasks the 'GenerateUpdatableHelp' task depends on. | +| $PSBPreference.TaskDependencies.Publish | 'Test' | Tasks the 'Publish' task depends on. | ## Examples diff --git a/build.ps1 b/build.ps1 index 06f810b..8529de6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,23 +3,22 @@ param( # Build task(s) to execute [parameter(ParameterSetName = 'task', position = 0)] [ArgumentCompleter( { - param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams) - $psakeFile = './psakeFile.ps1' - switch ($Parameter) { - 'Task' { - if ([string]::IsNullOrEmpty($WordToComplete)) { - Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name + param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams) + $psakeFile = './psakeFile.ps1' + switch ($Parameter) { + 'Task' { + if ([string]::IsNullOrEmpty($WordToComplete)) { + Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name + } else { + Get-PSakeScriptTasks -buildFile $psakeFile | + Where-Object { $_.Name -match $WordToComplete } | + Select-Object -ExpandProperty Name + } } - else { - Get-PSakeScriptTasks -buildFile $psakeFile | - Where-Object { $_.Name -match $WordToComplete } | - Select-Object -ExpandProperty Name + default { } } - Default { - } - } - })] + })] [string[]]$Task = 'default', # Bootstrap dependencies @@ -36,10 +35,10 @@ $ErrorActionPreference = 'Stop' # Bootstrap dependencies if ($Bootstrap.IsPresent) { - Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null + PackageManagement\Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null Set-PSRepository -Name PSGallery -InstallationPolicy Trusted if (-not (Get-Module -Name PSDepend -ListAvailable)) { - Install-module -Name PSDepend -Repository PSGallery + Install-Module -Name PSDepend -Repository PSGallery } Import-Module -Name PSDepend -Verbose:$false Invoke-PSDepend -Path './requirements.psd1' -Install -Import -Force -WarningAction SilentlyContinue @@ -48,7 +47,7 @@ if ($Bootstrap.IsPresent) { # Execute psake task(s) $psakeFile = './psakeFile.ps1' if ($PSCmdlet.ParameterSetName -eq 'Help') { - Get-PSakeScriptTasks -buildFile $psakeFile | + Get-PSakeScriptTasks -buildFile $psakeFile | Format-Table -Property Name, Description, Alias, DependsOn } else { Set-BuildEnvironment -Force diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..a8959d9 --- /dev/null +++ b/cspell.json @@ -0,0 +1,18 @@ +{ + "version": "0.2", + "ignorePaths": [], + "dictionaryDefinitions": [], + "dictionaries": [ + "powershell", + "csharp", + "json", + "xml", + "markdown" + ], + "words": [], + "ignoreWords": [ + "psake", + "MAML" + ], + "import": [] +} diff --git a/requirements.psd1 b/requirements.psd1 index 9f9d4b1..5e22bd3 100755 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -1,16 +1,16 @@ @{ - PSDependOptions = @{ + PSDependOptions = @{ Target = 'CurrentUser' } BuildHelpers = '2.0.16' Pester = @{ MinimumVersion = '5.6.1' - Parameters = @{ + Parameters = @{ SkipPublisherCheck = $true } } psake = '4.9.0' - PSScriptAnalyzer = '1.19.1' + PSScriptAnalyzer = '1.24.0' InvokeBuild = '5.8.1' platyPS = '0.14.2' } diff --git a/tests/TestModule/.build.ps1 b/tests/TestModule/.build.ps1 index 459b589..fad87e2 100644 --- a/tests/TestModule/.build.ps1 +++ b/tests/TestModule/.build.ps1 @@ -3,6 +3,6 @@ Import-Module ../../Output/PowerShellBuild -Force $PSBPreference.Build.CompileModule = $true -task Build $PSBPreference.build.dependencies +Task Build $PSBPreference.TaskDependencies.Build -task . Build +Task . Build diff --git a/tests/build.tests.ps1 b/tests/build.tests.ps1 index 0a8a6b7..9bbbdc3 100644 --- a/tests/build.tests.ps1 +++ b/tests/build.tests.ps1 @@ -1,21 +1,22 @@ -describe 'Build' { +# spell-checker:ignore excludeme +Describe 'Build' { BeforeAll { # Hack for GH Actions # For some reason, the TestModule build process create the output in the project root # and not relative to it's own build file. if ($env:GITHUB_ACTION) { - $testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'Output', 'TestModule', '0.1.0') + $script:testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'Output', 'TestModule', '0.1.0') } else { - $testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'tests', 'TestModule', 'Output', 'TestModule', '0.1.0') + $script:testModuleOutputPath = [IO.Path]::Combine($env:BHProjectPath, 'tests', 'TestModule', 'Output', 'TestModule', '0.1.0') } } - context 'Compile module' { + Context 'Compile module' { BeforeAll { Write-Host "PSScriptRoot: $PSScriptRoot" - Write-Host "OutputPath: $testModuleOutputPath" + Write-Host "OutputPath: $script:testModuleOutputPath" # build is PS job so psake doesn't freak out because it's nested Start-Job -ScriptBlock { @@ -26,48 +27,48 @@ describe 'Build' { } AfterAll { - Remove-Item $testModuleOutputPath -Recurse -Force + Remove-Item $script:testModuleOutputPath -Recurse -Force } - it 'Creates module' { - $testModuleOutputPath | Should -Exist + It 'Creates module' { + $script:testModuleOutputPath | Should -Exist } - it 'Has PSD1 and monolithic PSM1' { - (Get-ChildItem -Path $testModuleOutputPath -File).Count | Should -Be 2 - "$testModuleOutputPath/TestModule.psd1" | Should -Exist - "$testModuleOutputPath/TestModule.psm1" | Should -Exist - "$testModuleOutputPath/Public" | Should -Not -Exist - "$testModuleOutputPath/Private" | Should -Not -Exist + It 'Has PSD1 and monolithic PSM1' { + (Get-ChildItem -Path $script:testModuleOutputPath -File).Count | Should -Be 2 + "$script:testModuleOutputPath/TestModule.psd1" | Should -Exist + "$script:testModuleOutputPath/TestModule.psm1" | Should -Exist + "$script:testModuleOutputPath/Public" | Should -Not -Exist + "$script:testModuleOutputPath/Private" | Should -Not -Exist } - it 'Has module header text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Header' + It 'Has module header text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Header' } - it 'Has module footer text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Footer' + It 'Has module footer text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Module Footer' } - it 'Has function header text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function header' + It 'Has function header text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function header' } - it 'Has function footer text' { - "$testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function footer' + It 'Has function footer text' { + "$script:testModuleOutputPath/TestModule.psm1" | Should -FileContentMatch '# Function footer' } - it 'Does not contain excluded files' { - (Get-ChildItem -Path $testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 - "$testModuleOutputPath/TestModule.psm1" | Should -Not -FileContentMatch '=== EXCLUDE ME ===' + It 'Does not contain excluded files' { + (Get-ChildItem -Path $script:testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 + "$script:testModuleOutputPath/TestModule.psm1" | Should -Not -FileContentMatch '=== EXCLUDE ME ===' } - it 'Has MAML help XML' { - "$testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist + It 'Has MAML help XML' { + "$script:testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist } } - context 'Dot-sourced module' { + Context 'Dot-sourced module' { BeforeAll { # build is PS job so psake doesn't freak out because it's nested Start-Job -ScriptBlock { @@ -78,27 +79,27 @@ describe 'Build' { } AfterAll { - Remove-Item $testModuleOutputPath -Recurse -Force + Remove-Item $script:testModuleOutputPath -Recurse -Force } - it 'Creates module' { - $testModuleOutputPath | Should -Exist + It 'Creates module' { + $script:testModuleOutputPath | Should -Exist } - it 'Has PSD1 and dot-sourced functions' { - (Get-ChildItem -Path $testModuleOutputPath).Count | Should -Be 6 - "$testModuleOutputPath/TestModule.psd1" | Should -Exist - "$testModuleOutputPath/TestModule.psm1" | Should -Exist - "$testModuleOutputPath/Public" | Should -Exist - "$testModuleOutputPath/Private" | Should -Exist + It 'Has PSD1 and dot-sourced functions' { + (Get-ChildItem -Path $script:testModuleOutputPath).Count | Should -Be 6 + "$script:testModuleOutputPath/TestModule.psd1" | Should -Exist + "$script:testModuleOutputPath/TestModule.psm1" | Should -Exist + "$script:testModuleOutputPath/Public" | Should -Exist + "$script:testModuleOutputPath/Private" | Should -Exist } - it 'Does not contain excluded stuff' { - (Get-ChildItem -Path $testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 + It 'Does not contain excluded stuff' { + (Get-ChildItem -Path $script:testModuleOutputPath -File -Filter '*excludeme*' -Recurse).Count | Should -Be 0 } - it 'Has MAML help XML' { - "$testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist + It 'Has MAML help XML' { + "$script:testModuleOutputPath/en-US/TestModule-help.xml" | Should -Exist } } }