Skip to content

Commit 337a731

Browse files
Refactor module installation logic in main.ps1 to store the installation path in a variable
1 parent 2aeb7a5 commit 337a731

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

scripts/main.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ switch ($settings) {
2222
Write-Verbose " - Manifest file path: [$manifestFilePath]" -Verbose
2323
Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath
2424
$PSModulePath = $env:PSModulePath -split [System.IO.Path]::PathSeparator | Select-Object -First 1
25-
New-Item -Path "$PSModulePath/$moduleName/999.0.0" -ItemType Directory -Name "" -Force
26-
Copy-Item -Path $codePath -Destination "$PSModulePath/$moduleName/999.0.0" -Recurse -Force
25+
$moduleInstallPath = New-Item -Path "$PSModulePath/$moduleName/999.0.0" -ItemType Directory -Force
26+
Copy-Item -Path $codePath -Destination $moduleInstallPath -Recurse -Force
2727
}
2828
'SourceCode' {
2929
$codePath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path

scripts/tests/Module/PSModule/PSModule.Tests.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ Param(
1111
Describe 'PSModule - Module tests' {
1212
Context 'Module' {
1313
It 'The module should be importable' {
14-
{ Import-Module -Name $Path } | Should -Not -Throw
14+
{
15+
$moduleName = Split-Path -Path $Path -Leaf
16+
Import-Module -Name $moduleName
17+
} | Should -Not -Throw
1518
}
1619
}
1720

1821
Context 'Module Manifest' {
1922
BeforeAll {
23+
$moduleName = Split-Path -Path $Path -Leaf
2024
$moduleManifestPath = Join-Path -Path $Path -ChildPath "$moduleName.psd1"
2125
Write-Verbose "Module Manifest Path: [$moduleManifestPath]"
2226
}

0 commit comments

Comments
 (0)