Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 209bbef

Browse files
committed
Using cross-platform path separator
Using [IO.Path]::PathSeparator to determine correct path separator instead of the hardcoded ';'
1 parent c12a27a commit 209bbef

File tree

9 files changed

+31
-24
lines changed

9 files changed

+31
-24
lines changed

Modules/OperationValidation/OperationValidation.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ param (
263263
[string[]]$Name,
264264
[version]$Version
265265
)
266-
foreach($p in $env:psmodulepath.split(";"))
266+
foreach($p in $env:PSModulePath.split($script:pathSeparator))
267267
{
268268
if ( Test-Path -Path $p )
269269
{

OperationValidation/OperationValidation.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
$script:pathSeparator = [IO.Path]::PathSeparator
3+
24
# Dot source public/private functions
35
$public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Recurse -ErrorAction SilentlyContinue )
46
$private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -Recurse -ErrorAction SilentlyContinue )

OperationValidation/Private/Get-ModuleList.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Get-ModuleList {
1212

1313
if ($PSCmdlet.ParameterSetName -eq 'Name')
1414
{
15-
$pathsToSearch = $env:PSModulePath.Split(';')
15+
$pathsToSearch = $env:PSModulePath.Split($script:pathSeparator)
1616
}
1717
elseIf ($PSCmdlet.ParameterSetName -eq 'Path')
1818
{

OperationValidation/Public/Invoke-OperationValidation.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function Invoke-OperationValidation
230230
$testInfo = Get-OperationValidation @getOvfParams
231231
}
232232

233-
if ( $null -ne $testInfo )
233+
if ( $testInfo )
234234
{
235235
# first check to be sure all of the TestInfos are sane
236236
foreach($ti in $testinfo)
@@ -343,7 +343,7 @@ function Invoke-OperationValidation
343343
else
344344
{
345345
$pesterParams.Quiet = !$IncludePesterOutput
346-
}
346+
}
347347

348348
foreach($filePath in $TestFilePath) {
349349
write-progress -Activity "Invoking tests in $filePath"

Tests/Meta/Help.tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ $testModuleDir = (Resolve-Path -Path (Join-Path -Path $env:BHProjectPath -ChildP
66

77
# Get module commands
88
# Remove all versions of the module from the session. Pester can't handle multiple versions.
9+
$pathSeparator = [IO.Path]::PathSeparator
910
$savedModulePath = $env:PSModulePath
10-
if ( $env:psmodulepath.split(";") -notcontains $testModuleDir ) {
11-
$env:psmodulepath += ";$testModuleDir"
11+
if ( $env:PSModulePath.split($pathSeparator) -notcontains $testModuleDir ) {
12+
$env:PSModulePath += ($pathSeparator + $testModuleDir)
1213
}
13-
if ($env:PSModulePath.Split(';') -notcontains $env:BHModulePath) {
14-
$env:PSModulePath += ";$env:BHProjectPath"
14+
if ($env:PSModulePath.Split($pathSeparator) -notcontains $env:BHModulePath) {
15+
$env:PSModulePath += ($pathSeparator + $env:BHProjectPath)
1516
}
1617
Remove-Module Microsoft.PowerShell.Operation.Validation -Force -ErrorAction SilentlyContinue -Verbose:$false
1718
Import-Module $env:BHModulePath -Force -Verbose:$false

Tests/OperationValidation.Tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ $testModuleDir = (Resolve-Path -Path (Join-Path -Path $env:BHProjectPath -ChildP
44
Describe "OperationValidation Module Tests" {
55

66
BeforeAll {
7+
$pathSeparator = [IO.Path]::PathSeparator
78
$SavedModulePath = $env:PSModulePath
8-
if ( $env:psmodulepath.split(";") -notcontains $testModuleDir ) {
9-
$env:psmodulepath += ";$testModuleDir"
9+
if ( $env:PSModulePath.split($pathSeparator) -notcontains $testModuleDir ) {
10+
$env:PSModulePath += ($pathSeparator + $testModuleDir)
1011
}
11-
if ($env:PSModulePath.Split(';') -notcontains $env:BHModulePath) {
12-
$env:PSModulePath += ";$env:BHProjectPath"
12+
if ($env:PSModulePath.Split($pathSeparator) -notcontains $env:BHModulePath) {
13+
$env:PSModulePath += ($pathSeparator + $env:BHProjectPath)
1314
}
1415
Remove-Module Microsoft.PowerShell.Operation.Validation -Force -ErrorAction SilentlyContinue
1516
Import-Module $env:BHModulePath -Force

Tests/Unit/Get-OperationValidation.tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ $testModuleDir = (Resolve-Path -Path (Join-Path -Path $env:BHProjectPath -ChildP
44
Describe 'Get-OperationValidation' {
55

66
BeforeAll {
7+
$pathSeparator = [IO.Path]::PathSeparator
78
$savedModulePath = $env:PSModulePath
8-
if ($testModuleDir -notin $env:psmodulepath.split(";")) {
9-
$env:PSModulePath += ";$testModuleDir"
9+
if ($testModuleDir -notin $env:PSModulePath.split($pathSeparator)) {
10+
$env:PSModulePath += ($pathSeparator + $testModuleDir)
1011
}
11-
if ($env:BHProjectPath -notin $env:PSModulePath.Split(';')) {
12-
$env:PSModulePath += ";$env:BHProjectPath"
12+
if ($env:BHProjectPath -notin $env:PSModulePath.Split($pathSeparator)) {
13+
$env:PSModulePath += ($pathSeparator + $env:BHProjectPath)
1314
}
1415
Remove-Module Microsoft.PowerShell.Operation.Validation -Force -ErrorAction SilentlyContinue -Verbose:$false
1516
Import-Module $env:BHModulePath -Force -Verbose:$false

Tests/Unit/Invoke-OperationValidation.tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ $testModuleDir = (Resolve-Path -Path (Join-Path -Path $env:BHProjectPath -ChildP
44
Describe 'Invoke-OperationValidation' {
55

66
BeforeAll {
7+
$pathSeparator = [IO.Path]::PathSeparator
78
$savedModulePath = $env:PSModulePath
8-
if ($testModuleDir -notin $env:psmodulepath.split(";")) {
9-
$env:PSModulePath += ";$testModuleDir"
9+
if ($testModuleDir -notin $env:PSModulePath.split($pathSeparator)) {
10+
$env:PSModulePath += ($pathSeparator + $testModuleDir)
1011
}
11-
if ($env:BHProjectPath -notin $env:PSModulePath.Split(';')) {
12-
$env:PSModulePath += ";$env:BHProjectPath"
12+
if ($env:BHProjectPath -notin $env:PSModulePath.Split($pathSeparator)) {
13+
$env:PSModulePath += ($pathSeparator + $env:BHProjectPath)
1314
}
1415
Remove-Module Microsoft.PowerShell.Operation.Validation -Force -ErrorAction SilentlyContinue -Verbose:$false
1516
Import-Module $env:BHModulePath -Force -Verbose:$false

Tests/Unit/Module.tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
Describe 'Module' {
33

44
BeforeAll {
5+
$pathSeparator = [IO.Path]::PathSeparator
56
$savedModulePath = $env:PSModulePath
6-
if ( $env:psmodulepath.split(";") -notcontains $testModuleDir ) {
7-
$env:psmodulepath += ";$testModuleDir"
7+
if ( $env:PSModulePath.split($pathSeparator) -notcontains $testModuleDir ) {
8+
$env:PSModulePath += ($pathSeparator + $testModuleDir)
89
}
9-
if ($env:PSModulePath.Split(';') -notcontains $env:BHModulePath) {
10-
$env:PSModulePath += ";$env:BHProjectPath"
10+
if ($env:PSModulePath.Split($pathSeparator) -notcontains $env:BHModulePath) {
11+
$env:PSModulePath += ($pathSeparator + $env:BHProjectPath)
1112
}
1213
Remove-Module Microsoft.PowerShell.Operation.Validation -Force -ErrorAction SilentlyContinue
1314
Import-Module $env:BHModulePath -Force

0 commit comments

Comments
 (0)