From cf94fe7213ef021324cd4dd73252b29c6ac19857 Mon Sep 17 00:00:00 2001 From: Joel Timothy Oh Date: Sat, 20 Jul 2024 19:18:53 +0000 Subject: [PATCH] Docs (samples): Update test entrypoint script --- docs/samples/test/test.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/samples/test/test.ps1 b/docs/samples/test/test.ps1 index 274d537..52f21ed 100644 --- a/docs/samples/test/test.ps1 +++ b/docs/samples/test/test.ps1 @@ -9,17 +9,17 @@ Set-StrictMode -Version Latest $script:PesterDebugPreference_ShowFullErrors = $true try { - # Process variables - $MODULE_NAME = (Get-Item $PSScriptRoot/../).Name - $MODULE_DIR = "$PSScriptRoot/../src/$MODULE_NAME" | Convert-Path -ErrorAction Stop - $MODULE_MANIFEST = Get-Item "$MODULE_DIR/$MODULE_NAME.psd1" -ErrorAction SilentlyContinue - $SCRIPT_MODULE = Get-Item "$MODULE_DIR/$MODULE_NAME.psm1" -ErrorAction SilentlyContinue - $MODULE_PATH = if ($MODULE_MANIFEST) { $MODULE_MANIFEST.FullName } - elseif ($SCRIPT_MODULE) { $SCRIPT_MODULE.FullName } - else { throw "Unable to locate module manifest file '$MODULE_DIR/$MODULE_NAME.psd1' nor script module file '$MODULE_DIR/$MODULE_NAME.psm1'." } - Push-Location $PSScriptRoot + # Process variables + $moduleManifest = Get-Item ../src/*/*.psd1 -ErrorAction SilentlyContinue + $scriptModule = Get-Item ../src/*/*.psm1 -ErrorAction SilentlyContinue + $moduleItem = if ($moduleManifest) { $moduleManifest } + elseif ($scriptModule) { $scriptModule } + else { throw "Unable to locate module manifest file (.psd1) nor script module file (.psm1)." } + $MODULE_PATH = $moduleItem.FullName + $MODULE_DIR = $moduleItem.Directory + # Install Pester if needed "Checking Pester version" | Write-Host $pesterMinimumVersion = [version]'4.0.0'