Skip to content

Commit 1bce77d

Browse files
Add resources to path
1 parent ad15716 commit 1bce77d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/DscResource/PSResourceGetDSCResource.Tests.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ function SetupDsc {
1717
}
1818

1919
$script:dscExe = Get-Command -name dsc -CommandType Application | Select-Object -First 1
20+
21+
$loadedPSResourceGet = Get-Module PSResourceGet -ErrorAction SilentlyContinue
22+
$resources = Get-ChildItem $loadedPSResourceGet.ModuleBase/*resource.json -ErrorAction SilentlyContinue
23+
24+
if (-not $script:dscExe) {
25+
throw "Could not find dsc executable in PATH after setup."
26+
}
27+
28+
if (-not $resources.Count -ge 2) {
29+
throw "Expected at least 2 resource schema files in PSResourceGet module directory, found $($resources.Count)."
30+
}
31+
32+
$resourcePath = Split-Path $resources[0].FullName -Parent
33+
34+
Write-Verbose -Verbose "Adding DSC resource path to PATH environment variable: $resourcePath"
35+
36+
$env:PATH += "$pathSeparator$resourcePath"
2037
}
2138

2239
function SetupTestRepos {

0 commit comments

Comments
 (0)